• Hide columns in Workbook (2003)

    Author
    Topic
    #444023

    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?

    Viewing 0 reply threads
    Author
    Replies
    • #1072600

      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.Hidden = True
      Next wsh
      End Sub

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

      • #1072641

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

        • #1072645

          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?

          • #1072670

            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.

            • #1072672

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

    Viewing 0 reply threads
    Reply To: Hide columns in Workbook (2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: