+ Reply to Thread
Results 1 to 2 of 2

Trouble with hiding columns

Hybrid View

SeanDamnit Trouble with hiding columns 09-17-2012, 06:21 PM
SeanDamnit Re: Trouble with hiding... 09-17-2012, 06:36 PM
  1. #1
    Registered User
    Join Date
    07-25-2012
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Trouble with hiding columns

    There must be something really simple I'm missing here, but I just can't figure it out. I have a process that loops through every worksheet in my active workbook and adds a filter. Then for specific sheets I want specific columns hidden. The first part of the process works great, however the second part ends up hiding EVERY column instead of just the ones I specify. Here is the snippet of code:

    Sub FilterProcess()
    Dim District As String, ws As Worksheet, header As Range, lc As Long, varRow As Integer
    
    For Each ws In ActiveWorkbook.Worksheets
    
    ''''''''''''''''''''''''''''''''''''''''
    ' (code that adds a filter and defines the header row for each worksheet is here) '
    ''''''''''''''''''''''''''''''''''''''''
    
    If ws.Name = "Buyback" Then
        For Each i In header
            If i.Value = "Store Name" Or _
                        "Region" Or _
                        "Location Type" Or _
                        "Receipt Date"
            Then
                Columns(i.Column).EntireColumn.Hidden = True
            End If
        Next i
    End If
                        
    Next ws
    
    
    End Sub
    This ends up hiding ALL columns instead of just the ones specified. If I remove the multiple OR arguments then it properly hides just the one column. Please let me know what I'm missing here!

    Thanks!

  2. #2
    Registered User
    Join Date
    07-25-2012
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Trouble with hiding columns

    Figured it out. Of course it was something simple and stupid. I need to put i.Value = ... for each of the or arguments. Please ignore me!

+ 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