+ Reply to Thread
Results 1 to 6 of 6

Hide Blank Rows based on 2 columns

Hybrid View

  1. #1
    Registered User
    Join Date
    07-12-2007
    Posts
    24

    Hide Blank Rows based on 2 columns

    I have a bit of code that I used a while back but need to tweak it. The code currently works well and hides the blank rows at the bottom of a single column range. This is what I need now:
    -I want the code to look at the data in BOTH columns C and D. Then hide the rows that are below the last line whether its in column C or D. I have tried just changing the Range in the code but that doesn't seem to work. Any help would be great.
    Thanks
    Rob


    Dim rng As Range
      Range("C5:C30").EntireRow.Hidden = False
      For Each ce In Range("C5:C30")
        If IsEmpty(ce) Then
          If rng Is Nothing Then
            Set rng = ce
          Else
            Set rng = Union(rng, ce)
          End If
        End If
      Next ce
      rng.EntireRow.Hidden = True

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Try

    Dim rng As Range
      Range("C5:C30").EntireRow.Hidden = False
      For Each ce In Range("C5:C30")
        If IsEmpty(ce) And IsEmpty(ce.Offset(0, 1)) Then
          If rng Is Nothing Then
            Set rng = ce
          Else
            Set rng = Union(rng, ce)
          End If
        End If
      Next ce
      rng.EntireRow.Hidden = True

    rylo

  3. #3
    Registered User
    Join Date
    07-12-2007
    Posts
    24
    Thanks Rylo - you came to rescue again.

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    So why did you cross post it then.

    Please read forum rules and message to cross posters below and then add the loink to the other forum

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  5. #5
    Registered User
    Join Date
    07-12-2007
    Posts
    24
    Your right my mistake, her is the link to the other forum. Won't happen again.

    http://www.mrexcel.com/forum/showthr...=1#post1454177

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Just change the range

    Dim rng As Range
    Dim ce As Range
      Range("C5:d30").EntireRow.Hidden = False
      For Each ce In Range("C5:d30")
        If IsEmpty(ce) Then
          If rng Is Nothing Then
            Set rng = ce
          Else
            Set rng = Union(rng, ce)
          End If
        End If
      Next ce
      rng.EntireRow.Hidden = True
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ Reply to Thread

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