Design Mode in the
Developer tab of the ribbon and right-click on the Yes button and choose
View Code. (I've renamed the button "obYes".)
That will bring up the VBA code editor with an empty procedure for the code that will be run each time the Yes option button is chosen.
Here's where some choices need to be made on exactly what should happen when the Yes button is chosen.
For this example, I've assumed that three things should occur:
- The cell where the user will enter the brand of the laptop should be selected.
- The fill color of that cell should change.
- A message should appear to reinforce what the user is expected to do.
The best way to figure out what code is needed is to use the macro recorder to generate the basic code, which can then be customized (and usually shortened) to do exactly what you want).
It may be necessary to supplement the macro recorder with a Google search. The first two of the things are easy to find using the search terms "excel vba select cell" and "excel vba set cell color".
The third one - the message to the user - is a little tougher, but only because it's necessary to decide exactly how the message should be delivered: A popup box? Text inserted into a neighboring cell? Something else?
In this case, I've chosen Excel's data validation feature, which conveniently can be set to pop up a message when a cell is selected.
Here's the code for both the Yes and the No buttons. (The cryptic 7-digit number for the cell interior color in the Yes code is what the macro recorder recorded when I selected green for the fill color.)
The result pretty much works as intended. When the Yes button is chosen, the data entry cell is selected, its color turns green, and a message pops up. When the No option button is selected, the cell is cleared.