VBA Code not working

jrisebo

Active Member
Joined
Mar 15, 2011
Messages
319
Office Version
  1. 365
Platform
  1. Windows
Attached is my code. It gives me a error when I open it. I had it working, saved it, closed it, and reopened and wal-la the error.

I dont know how to attach the whole spreadsheet, that might be best.

The jist of the code is to show two different pictures based on whats selected in the spreadsheet.

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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
When opening the file, it says File error: data may have been lost.

then, you click ok on that, and the error is Compile error: cant find project or library
 
Upvote 0
If you can open the file goto the VBE (Alt+F11) and then Tools>References...

Are there any entries with MISSING next to them?
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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