Run-Time error 424 Object required

Dspace

New Member
Joined
Nov 2, 2020
Messages
17
Office Version
  1. 365
Platform
  1. Windows
Think I've got a simple error here. I keep getting the Object required error on the following.

Sub UnHideITSC()
ActiveSheet.Unprotect Password:="test$"
For Each cell In Range("b14:b405")
If cell.Value = 1 Then
entire.Row.unHidden
Else: entire.Row.Hidden
End If
Next cell
ActiveSheet.Protect Password:="test$"
End Sub

I know its going to be something simple but its really aggravating me. Thanks!
Don't forget to vote tomorrow!
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hi & welcome to MrExcel.
How about
VBA Code:
Sub UnHideITSC()
ActiveSheet.Unprotect Password:="test$"
For Each cell In Range("b14:b405")
   If cell.Value = 1 Then
      cell.EntireRow.Hidden = False
   Else
      cell.EntireRow.Hidden = True
   End If
   Next cell
ActiveSheet.Protect Password:="test$"
End Sub
 
Upvote 0
Solution
Try

VBA Code:
Sub UnHideITSC()
ActiveSheet.Unprotect Password:="test$"
For Each cell In Range("b14:b405")
    If cell.Value = 1 Then
        Rows(cell.Row).Hidden = False
    Else
        Rows(cell.Row).Hidden = True
    End If
Next cell
ActiveSheet.Protect Password:="test$"
End Sub
 
Upvote 0
You can also get rid of the If like
VBA Code:
Sub UnHideITSC()
ActiveSheet.Unprotect Password:="test$"
For Each cell In Range("b14:b405")
   cell.EntireRow.Hidden = cell.Value <> 1
Next cell
ActiveSheet.Protect Password:="test$"
End Sub
 
Upvote 0
Thank you all!
My forehead & monitor thank you! (They were about to meet at fast speeds)
Just learning to expand my VBA knowledge.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,871
Members
449,054
Latest member
juliecooper255

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