Consulting

Results 1 to 4 of 4

Thread: Solved: hide columns based on value

  1. #1
    VBAX Regular
    Joined
    May 2007
    Posts
    72
    Location

    Solved: hide columns based on value

    How can I ask Excel to hide columsn based on the value in row 6? Basically anytime the word "MCF" shows up in row 6, the whole column should be hidden.
    Data range is from column A to AK.
    Thank you!

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Sub HideData()
    Dim mpLastCol As Long
    Dim i As Long

    With ActiveSheet

    mpLastCol = .Cells(6, .Columns.Count).End(xlToLeft).Column
    For i = 1 To mpLastCol
    .Columns(i).Hidden = .Cells(6, i).Value = "MCF"
    Next i
    End With

    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    May 2007
    Posts
    72
    Location
    brilliance
    thank you

  4. #4
    VBAX Mentor anandbohra's Avatar
    Joined
    May 2007
    Location
    Mumbai
    Posts
    313
    Location
    kindly mark your thread as solved the moment u got acceptable reply as it saves time in looking thread which r already been solved.

    so pl from next time mark thread as solved as u get required reply.

    this option is located in the thread tools.

Posting Permissions

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