Results 1 to 3 of 3

Hiding a column based on 2 or more cell values

Threaded View

  1. #1
    Registered User
    Join Date
    10-12-2010
    Location
    Leeds, England
    MS-Off Ver
    Excel 2003
    Posts
    2

    Hiding a column based on 2 or more cell values

    Hi,

    I am trying to hide column 'E' when either cell C8 or C16 is empty and show it when both cells are completed. The following code doesn't quite work.

    Private Sub Worksheet_Change(ByVal Target As Range)
      If Target.Address = "$C$16" And Target.Value = "" Or Target.Address = "$C$8" And Target.Value = "" Then
    Range("E:E").EntireColumn.Hidden = True
    
    ElseIf (Target.Address = "$C$16" And Target.Value <> "") And (Target.Address = "$C$8" And Target.Value <> "") Then
    Range("E:E").EntireColumn.Hidden = False
    
    End If
    End Sub
    I think its to do with the 'And' in the ElseIf statement but I don't know much about VBA so I could do with some help. Thanks
    Last edited by excelfan2010; 10-12-2010 at 09:16 AM.

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