+ Reply to Thread
Results 1 to 5 of 5

Conditional Formatting to Hide Rows or Columns?

  1. #1
    Registered User
    Join Date
    09-26-2006
    Location
    Windsor, CA
    Posts
    3

    Question Conditional Formatting to Hide Rows or Columns?

    I'm currently using Excel 2002 SP3. I use conditional formatting in many of my spreadsheets, but I haven't been able to figure out how to "Hide" a row or column based on a certain condition. Is there a method for doing this already built into Excel's functionality, and if not, is there a way to do it with VBA? Any help would be greatly appreciated! Thank you.
    Steven P. Czegus
    Program Planning Analyst
    Sonoma County Human Services Department

  2. #2
    Valued Forum Contributor
    Join Date
    12-16-2004
    Location
    Canada, Quebec
    Posts
    363
    Hi

    Not sure on the question, but this will hide a column a if the value is greater then 5 (in cell a1)

    Sub hide_val()
    Range("a1").Select
    val_check = ActiveCell.Value
    If val_check > 5 Then
    Selection.EntireColumn.Hidden = True
    Else
    Selection.EntireColumn.Hidden = False
    End If
    End Sub

  3. #3
    Registered User
    Join Date
    09-26-2006
    Location
    Windsor, CA
    Posts
    3

    Question

    Thank you for the suggestion! To clarify my situation, I'm working with an attendance form that has over 45 rows to accomodate different activities, and 16 columns to accomodate each day in the timeframe (1st to the 15th, or 16th to the end of the month). I want the attendance form to be as uncluttered as possible, so I'm looking for a way to automatically hide the rows (row height=0) that aren't being used, and to automatically hide the columns (column width=0) that aren't necessary for the current timeframe (i.e. the last 3 columns when the timeframe is February 16th to February 28th).

    For simplicity sake, let's say the range is rows 1-10, and I'm trying to individually hide rows where the cell in the A column contains the word "HIDE".

    Jetted, the VBA that you listed ... is this something that runs automatically, or do you have to "call" the routine by connecting it to a button or something of that nature?

    Thank you in advance for any help you can provide!

  4. #4
    Valued Forum Contributor
    Join Date
    12-16-2004
    Location
    Canada, Quebec
    Posts
    363
    Hi

    Can you provide a sample of you works.

    Thanks
    Denis

  5. #5
    Registered User
    Join Date
    09-26-2006
    Location
    Windsor, CA
    Posts
    3

    Smile

    Below is the code that I finally used to get this to work for me:

    Please Login or Register  to view this content.
    Thank you for your help! Let me know if you have any questions.

+ 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