VBA error message "Range of Object_ Worksheet failed"

kcc2009

New Member
Joined
May 13, 2016
Messages
6
Hi, having issues with my code and getting the error message "<Method 'Range' of object '_Worksheet' failed>"

My code below, I just want to hide rows within the worksheet. this code worked fine before but when I made a change to the row numbers, I received this error message. Can anyone help? Thanks!!



Private Sub ListBox1_Click()

End Sub

Private Sub ComboBox1_Change()

End Sub
Private Sub Worksheet_Change(ByVal Target As Range)

If Sheets("REPORT").Range("F5") = Sheets("REPORT").Range("AL3") Then
Sheets("REPORT").Rows.Hidden = False
Range("A36,A38,A39,A92:A94,A171").EntireRow.Hidden = True
'Else: Sheets("REPORT").Range("A36,A38,A39,A92:A94,A171").EntireRow.Hidden = False
End If

If Sheets("REPORT").Range("F5") = Sheets("REPORT").Range("AL4") Then
Sheets("REPORT").Rows.Hidden = False
Range("A36,A38,A39,A92:A94,A169:170").EntireRow.Hidden = True
End If

If Sheets("REPORT").Range("F5") = Sheets("REPORT").Range("AL6") Then
Sheets("REPORT").Rows.Hidden = False
Range("A37,A170:171").EntireRow.Hidden = True
End If

If Sheets("REPORT").Range("F5") = Sheets("REPORT").Range("AL5") Then
Sheets("REPORT").Rows.Hidden = False
Range("A37,A168:169").EntireRow.Hidden = True
End If

If Sheets("REPORT").Range("F5") = Sheets("REPORT").Range("AL7") Then
Sheets("REPORT").Rows.Hidden = False
Range("A170:171").EntireRow.Hidden = True
End If

If Sheets("REPORT").Range("F5") = Sheets("REPORT").Range("AL2") Then
Sheets("REPORT").Rows.Hidden = False

End If
End Sub
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
For some reason the exact error message didn't post. The error is:< Range of object '_worksheet failed >
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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