Hiding Rows with Macros

  • Thread starter Thread starter maacmaac
  • Start date Start date
M

maacmaac

I want to hide rows based on the value given in G4. Example: if G4=6,
then hide rows 17-25; if G4=3, then hide rows 14-20; if G4=11,
then hide rows 22-25.

I am using the following macro, but it does not work.


Sub Hide_Rows()
'
' Hide_Rows Macro
'

' Rows.Offset("A14:A25").EntireRow.Hidden = True
End Sub



Please help.

Thanks,

Attachment filename: hide rows.xls
Download attachment: http://www.excelforum.com/attachment.php?postid=383145
 
Hi

Sub Hide_Rows()
Rows("14:25").Hidden = True
End Sub

I am not able to spot any linear logic from your 3 samples, so you (or anyone else
brighter than me) must take it from here.
 
Sub CheckandHide()

Dim strValue As String

strValue = Range("G4").Value

If strValue = 6 Then
Range("A17:A25").Select
Selection.EntireRow.Hidden = True
End If

If strValue = 3 Then
Range("A14:A20").Select
Selection.EntireRow.Hidden = True
End If

' etc and so forth for all your citeria

End Sub

HTH
Ed
 
Back
Top