Hide rows

radlernyc

Board Regular
Joined
Jun 9, 2005
Messages
69
I need to set myRowRange = Range("A" & lastline% : "A57"). In essence I need to hide rows Alastline to A57. The code is below. Thanks for all the help.


Code:
Sub hiderows()

Dim myRowRange As Range
    Dim myColRange As Range
    Dim cell As Range
    
   Sheets("peer").Select
    
    peernum% = Range("peernum")
    
    lastline% = 7 + peernum%
           
           
'   Hide rows with no data
'   Define which cells to look at to hide rows
    
    Sheets("data").Select
    
    Set myRowRange = Range("A" & lastline% : "A57")
    For Each cell In myRowRange
        If cell = 0 Then cell.EntireRow.Hidden = True
    Next cell
    

End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
This work for you?

Code:
Sub hiderows()
Dim myRowRange As Range
Dim cell As Range
Dim peernum As Integer, lastline As Long
       
With Sheets("peer")
    peernum = .Range("peernum").Value
    lastline = 7 + peernum
End With
       
With Sheets("data")
    Set myRange = .Range("A57:A" & lastline)
    For Each cell In myRowRange
        If cell.Value = 0 Then cell.EntireRow.Hidden = True
    Next cell
End With

End Sub
 
Upvote 0
Thanks for the help, but it is crapping out at line "For Each cell In myRowRange"

Thanks for all the help
 
Upvote 0
Oh, shoot. Sorry, myfault. I changed the variable name, but forgot to change it in that line.

Change myRange to myRowRange
 
Upvote 0

Forum statistics

Threads
1,203,553
Messages
6,056,063
Members
444,841
Latest member
SF_Marnie

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