I have the following 2 events which run perfectly well independently in an excel worksheet
However when the first code runs it triggers the second code event and i get an error Run time error '1004' Select method of range class failed
What am i doing wrong here?
This code sets everything in the range to false. The true or false values are generated using checkboxes
This code hides/unhides data on another worksheet to generate selected data points for chart
However when the first code runs it triggers the second code event and i get an error Run time error '1004' Select method of range class failed
What am i doing wrong here?
This code sets everything in the range to false. The true or false values are generated using checkboxes
Code:
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Application.Calculation = xlManual
Application.EnableEvents = False
Application.Sheets("708 Earthworks").Activate
Application.Sheets("708 Earthworks").Range("i6:i66").Value = False
Application.Sheets("708 Earthworks").Range("F4").Select
Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
This code hides/unhides data on another worksheet to generate selected data points for chart
Code:
Private Sub CheckBox29_Click()
Application.ScreenUpdating = False
Application.Calculation = xlManual
Application.Sheets("708 Workings").Activate
Dim MyCell As Range, MyRange As Range
Set MyRange = Application.Sheets("708 Workings").Range("o502:o664")
For Each MyCell In MyRange
MyCell.Select
If MyCell.Value <> 0 Then
Selection.EntireRow.Hidden = True
Else
Selection.EntireRow.Hidden = False
End If
Next MyCell
Application.Sheets("708 Earthworks").Activate
Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
End Sub