Code to change picture in a spreadsheet not working

jrisebo

Active Member
Joined
Mar 15, 2011
Messages
312
Office Version
  1. 365
Platform
  1. Windows
I have a spreadsheet, when you pull down a menu, you can select two options that will change a picture in a spreadsheet. It was working, but now I get a error thats "Compile Error, cant find project or library"

Heres the code. not sure what to do.

Private Sub Worksheet_Calculate()
HideSignals
Select Case [h1]
Case 1: Shapes("OSERIES1").Visible = msoTrue
Case 2: Shapes("BSERIES1").Visible = msoTrue
End Select
Select Case [h1]
Case 1: Shapes("OSERIES2").Visible = msoTrue
Case 2: Shapes("BSERIES2").Visible = msoTrue
End Select
Select Case [h1]
Case 1: Shapes("OSERIES3").Visible = msoTrue
Case 2: Shapes("BSERIES3").Visible = msoTrue
End Select
Select Case [h1]
Case 1: Shapes("OSERIES4").Visible = msoTrue
Case 2: Shapes("BSERIES4").Visible = msoTrue
End Select
Select Case [h1]
Case 1: Shapes("OSERIES5").Visible = msoTrue
Case 2: Shapes("BSERIES5").Visible = msoTrue
End Select
Select Case [h1]
Case 1: Shapes("OSERIES6").Visible = msoTrue
Case 2: Shapes("BSERIES6").Visible = msoTrue
End Select
Select Case [h1]
Case 1: Shapes("OSERIES7").Visible = msoTrue
Case 2: Shapes("BSERIES7").Visible = msoTrue
End Select
End Sub

Sub HideSignals()
Dim i As Integer
For i = 1 To 7
Shapes("OSERIES" & i).Visible = msoFalse
Shapes("BSERIES" & i).Visible = msoFalse
Next i
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, [H2]) Is Nothing Then
'this does not calculate the worksheet. It just calls the Calculate event.
Worksheet_Calculate
End If
End Sub
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Private Sub Worksheet_Calculate() is the first, highlighted yellow

Select Case [h1]
highlighted blue
 
Upvote 0
Your code compiles fine for me. Do you have any References marked as MISSING?

Under the tools menu, the references selections is greyed out, so not sure whats going on. Anyway I can upload the spreadsheet?
 
Upvote 0

Forum statistics

Threads
1,215,470
Messages
6,124,992
Members
449,201
Latest member
Lunzwe73

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