Results 1 to 5 of 5

Macro to hide empty rows

Threaded View

  1. #1
    Registered User
    Join Date
    11-03-2012
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2007
    Posts
    32

    Macro to hide empty rows

    Hi
    I have a macro on a sheet to hide all empty rows based on the values of cells A55 to A215. The value comes from a droplist that is filled by the users. If the value “1” appears, the row is visible, if nothing appears, the row should hide automatically.

    The macro is working if I change the value manually in column A ("1" or empty) but the fact that the value comes from a Vlookup formula linked to a drop list (H29:H36) caused some problems... So according to the selection in the drop list, the value changes from empty to "1" and this must decide if the row is hide or not. The problem is when I change the value from the droplist, nothing happen. Do you think you could find out why?

    Thanks,

    Private Sub Worksheet_Change(ByVal Target As Range)
     If Not Intersect(Target, Range("A55:A255")) Is Nothing Then
     Call HideRows2
     End If
     End Sub
     
     Sub HideRows2()
        Dim LR As Long, i As Long
    
        LR = Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlFormulas).Row
    
        For i = 55 To LR
        If Cells(i, 1) = "" Then Rows(i).EntireRow.Hidden = True
        If Cells(i, 1).HasFormula And Cells(i, 1) = "" Then
        Rows(i).EntireRow.Hidden = True
        ElseIf Cells(i, 1).HasFormula And Cells(i, 1) = 0 Then
        Rows(i).EntireRow.Hidden = True
        End If
     Next i
    End Sub
    Dropbox link:
    https://dl.dropbox.com/u/93601544/TE...WS%20EXTR.xlsm
    Last edited by nomis6565; 11-24-2012 at 04:00 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1