Results 1 to 28 of 28

Conditionally Hide Columns based on cell result

Threaded View

  1. #1
    Registered User
    Join Date
    06-30-2010
    Location
    Tucson, Arizona
    MS-Off Ver
    Excel 2007
    Posts
    58

    Conditionally Hide Columns based on cell result

    Hello. I am new to manipulating excel via VBA. I am trying to conditionally hide an entire coloumn based on a cell result in the given column. I have gotten only the below code to work.
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        If Range("B3").Value = 0 Then
            Columns("B").EntireColumn.Hidden = True
        Else
            Columns("B").EntireColumn.Hidden = False
        End If
    End Sub
    I can get this to hide coloumn B as I want, but it only works for coloumn B (obviously). I want it to work for a range of coloumns from B to BA such that B3=0-->hide colB , C3=""-->display col C , D3=0-->hide colD , ... etc. up to coloumn BA

    I'm assuming the answer is as simple as nesting the above code in a while loop or something similar from B:BA, but I don't have the know-how to program such a macro.

    Thanks in Advance!
    Last edited by montego; 07-01-2010 at 01:04 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