Need help with a Hide rows Macro

copleyr

Active Member
Joined
Aug 24, 2009
Messages
381
Hello all,

I am in desperate need of a macro that will look in column "AU" of the current sheet, rows 15-45, and rows 50-80. For any cell in that area that displays a 0, i need the macro to hide that whole row.

Thank you for your help in advance!
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
perhaps:

Code:
Public Sub hidezerovalues()
Dim i   As Long
Application.ScreenUpdating = False
For i = 15 To 45
    If Range("AU").Value = 0 Then
        rows(i).Hidden = True
    End If
Next i
For i = 50 To 80
    If Range("AU").Value = 0 Then
        rows(i).Hidden = True
    End If
Next i
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thanks Mr Kowz

I got a run-time error '1004':
Method 'Range' of object'_Global' failed.

Any ideas?

it was pointing to this

If Range("AU").Value = 0 Then
 
Upvote 0
Code:
Public Sub hidezerovalues()
Dim i   As Long
Application.ScreenUpdating = False
For i = 15 To 45
    If Range("AU" & i).Value = 0 Then
        rows(i).Hidden = True
    End If
Next i
For i = 50 To 80
    If Range("AU" & i).Value = 0 Then
        rows(i).Hidden = True
    End If
Next i
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Hey,

Was wondering if I can get a reverse Macro to unhide all the rows I had just hidden.

Thank you in advance!
 
Upvote 0
Try:

Code:
Public Sub hidezerovalues()
Dim i   As Long
Application.ScreenUpdating = False
For i = 15 To 45
    If Range("AU" & i).Value = 0 Then
        rows(i).Hidden = False
    End If
Next i
For i = 50 To 80
    If Range("AU" & i).Value = 0 Then
        rows(i).Hidden = False
    End If
Next i
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,233
Members
452,898
Latest member
Capolavoro009

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