Selectable Button/Icon for "Yes" and "No" Responses (VBA)

Disarmonious

Board Regular
Joined
Oct 31, 2016
Messages
151
Office Version
  1. 365
Before I begin, I am a VBA beginner. I ask for your patience. Thank you, in advance!

I created an icon and assigned a macro that when selected, the word, "Yes" appears on cell B2.

Now, I'm looking for the word "No" to appear in the same cell, B2 when this icon is selected again. So, essentially, this icon would act as a "switch" by telling cell B2 to return the words "Yes" and "No" when the user selects it.

Here's my VBA code:

Sub Image1_Click()

ActiveSheet.Range("B2").Value = "Yes"


End Sub
 
Hi
try

VBA Code:
Sub Image1_Click()
    With ActiveSheet.Range("B2")
        .Value = IIf(.Value = "Yes", "No", "Yes")
    End With
End Sub

Dave
 
Upvote 0
Hi
try

VBA Code:
Sub Image1_Click()
    With ActiveSheet.Range("B2")
        .Value = IIf(.Value = "Yes", "No", "Yes")
    End With
End Sub

Dave

dmt32

I'm sorry I didn't respond sooner as I've been out on an emergency but thank you very much for your help! Have a good day!
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top