Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Apr 2004
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro to hide rows in Excel 2003

    I'd like to create a macro that will look at each cell in a specific column for a specific range and when that cell meets a certain condition such as having a specific name the macro will then hide that row. Any ideas?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro to hide rows in Excel 2003

    You're not very specific, so here is an example. You'll have to adapt it to your needs:

    Sub HideSomeRows()
    Const lngCol As Long = 3 ' work with column C
    Dim lngRow As Long
    Dim i As Long

    ' Locate last filled cell in column
    lngRow = Cells(65536, lngCol).End(xlUp).Row

    ' Work our way back up to the top
    For i = lngRow To 1 Step -1
    ' Plug in your condition here
    If Cells(i, lngCol) = "Woody" Then
    Rows(i).Hidden = True
    End If
    Next i
    End Sub

  3. #3
    Star Lounger
    Join Date
    Apr 2004
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to hide rows in Excel 2003

    Hans,

    Wow! That was perfect. Does just what I wanted it to. Thank you very much!!

    Kent

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •