problem with code

chobanne

Active Member
Joined
Jul 3, 2011
Messages
269
hello all

I make this code and have problem with it

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Range("ah1") = 1 Then
ActiveSheet.Shapes("Picture 15").Visible = True
Else:
ActiveSheet.Shapes("Picture 15").Visible = False
End If
End Sub

The picture don't automatically hide or unhide until i click some random cell in sheet.

Can someone pls help me what to add in code to avoid subsequent click
 
its form check box, thats why i have AH1 value, For activex i dont need range AH1 i think, i think code must be modify
i will prefere if it will run with form control button because many others formula i have depends on that button and some conditional formating
 
Upvote 0

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
What about not using a worksheet event and just assigning the macro to the button ?

In a Standard Module (ie right click on modules and Insert Module), paste the code below.
Then right click on the Form Checkbox and Assign Macro and select the macro below.

Rich (BB code):
Sub CheckBox1_Click()
    If ActiveSheet.Range("AH1") = 1 Then
        ActiveSheet.Shapes("Picture 15").Visible = True
    Else:
        ActiveSheet.Shapes("Picture 15").Visible = False
    End If
End Sub
 
Upvote 0
Solution
What about not using a worksheet event and just assigning the macro to the button ?

In a Standard Module (ie right click on modules and Insert Module), paste the code below.
Then right click on the Form Checkbox and Assign Macro and select the macro below.

Rich (BB code):
Sub CheckBox1_Click()
    If ActiveSheet.Range("AH1") = 1 Then
        ActiveSheet.Shapes("Picture 15").Visible = True
    Else:
        ActiveSheet.Shapes("Picture 15").Visible = False
    End If
End Sub
it works thank you
 
Upvote 0

Forum statistics

Threads
1,215,149
Messages
6,123,311
Members
449,095
Latest member
Chestertim

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