Results 1 to 6 of 6
  1. #1
    4 Star Lounger
    Join Date
    May 2003
    Location
    Austin
    Posts
    401
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hide columns in Workbook (2003)

    I want to write a script that hides columns B-D-E-F-H-L-P of all worksheets in a workbook.

    I would like it to not run ON OPEN but if I deny macros ON OPEN, I can still paste the data in ALL the columns and not throw off my data.

    But the users should enable the macro and then it would globally hide the applicable columns.
    If I guess correctly, that how it would run anyway.

    How would this be done?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hide columns in Workbook (2003)

    Here is a macro that hides the specified columns:

    Sub HideSomeColumns()
    Dim wsh As Worksheet
    For Each wsh In ActiveWorkbook.Worksheets
    wsh.Range("B:B,D:F,H:H,L:L,P:P").EntireColumn.Hidd en = True
    Next wsh
    End Sub

    I don't understand the rest of your question, sorry.

  3. #3
    4 Star Lounger
    Join Date
    May 2003
    Location
    Austin
    Posts
    401
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hide columns in Workbook (2003)

    Great! What if I wanted to extend that to a conditional hiding of rows if a value was null or blank?
    Thanks again

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hide columns in Workbook (2003)

    If what value is blank? A cell on a specific sheet? If so, do you want to not hide any coloumns on any of the sheets? A specific cell on each sheet, and if so do you only want to not hide the columns on that sheet? The value of some variable or parameter, and if so what do you want to hide and not hide?
    Legare Coleman

  5. #5
    4 Star Lounger
    Join Date
    May 2003
    Location
    Austin
    Posts
    401
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hide columns in Workbook (2003)

    My apologies. That was very vague of me.
    My intention is to check for a (NULL or blank) in a cell (say C:2)
    If it is NULL or blank then just hide ROW#2

    There would be a limit in the array. It wouldn't have to be for all 65k rows.
    The upper limit of the array would prob be 1000.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hide columns in Workbook (2003)

    You can probably do this without code, instead using AutoFilter, by selecting (NonBlanks) from the dropdown in the appropriate column header.

Posting Permissions

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