Automatically Run Macro When A Cell Value Changes

Joined
Jan 6, 2014
Messages
2
Hello Forum! I'm struggling with a macro issue and am hoping to find insight from the higher power that is you. Essentially, I'm trying to build a macro that runs every time a cell value is changed (in this case cell AC4). The purpose of that macro is to show / make visible one of 4 different pictures based on the value of cell AC4. The value of that cell will either be 1,2,3 or 4, and each of those numbers will show 1 picture and hide the other 3.

I think most of the code I have below is functional for my needs, but I can't seem to get the auto-run when the value of cell AC4 changes to work... that bit of code is in the first 2 lines of my code below. After the part that says "Is Nothing Then" I think I want to put my macro name, and I think I did that, but I'm getting an error. This is one of those situations where I'm not good enough with Excel to know what it is I don't know... :confused: Any assistance or suggestions concerning direction on how I could make my cobbled together code functional would be greatly appreciated. Thank you in advance for any assistance!

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Target.Worksheet.Range("$A$C4")) Is Nothing Then Worksheet_Change
If Target.Address = "$AC$4" Then
If Target.Value = 0 Then
ActiveSheet.Shapes("Group 9").Visible = True
ActiveSheet.Shapes("Group 17").Visible = True
ActiveSheet.Shapes("Group 25").Visible = True
ActiveSheet.Shapes("Group 33").Visible = True
If Target.Address = "$AC$4" Then
If Target.Value = 1 Then
ActiveSheet.Shapes("Group 9").Visible = True
ActiveSheet.Shapes("Group 17").Visible = False
ActiveSheet.Shapes("Group 25").Visible = False
ActiveSheet.Shapes("Group 33").Visible = False
If Target.Address = "$AC$4" Then
If Target.Value = 2 Then
ActiveSheet.Shapes("Group 9").Visible = False
ActiveSheet.Shapes("Group 17").Visible = True
ActiveSheet.Shapes("Group 25").Visible = False
ActiveSheet.Shapes("Group 33").Visible = False
If Target.Address = "$AC$4" Then
If Target.Value = 3 Then
ActiveSheet.Shapes("Group 9").Visible = False
ActiveSheet.Shapes("Group 17").Visible = False
ActiveSheet.Shapes("Group 25").Visible = True
ActiveSheet.Shapes("Group 33").Visible = False
If Target.Address = "$AC$4" Then
If Target.Value = 4 Then
ActiveSheet.Shapes("Group 9").Visible = False
ActiveSheet.Shapes("Group 17").Visible = False
ActiveSheet.Shapes("Group 25").Visible = False
ActiveSheet.Shapes("Group 33").Visible = True
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Sub
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Delete this line

If Not Intersect(Target, Target.Worksheet.Range("$A$C4")) Is Nothing Then Worksheet_Change

Plus the code located in a Worksheet Module?
 
Upvote 0
Thanks for responding Cool blue.

Sadly, I'm not even sure what you're talking about with the located in a Worksheet Module part :(

That said, not surprisingly I still can't seem ot make the file work for me.

I tried eliminating that line as you suggested but couldn't make that work, so I then tried adding different code but again failed... Is there any way I could send you my file so you could very quickly tell me what over the top obvious thing I'm missing?
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,988
Members
452,373
Latest member
TimReeks

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