hide columns

orsm6

Well-known Member
Joined
Oct 3, 2012
Messages
511
Office Version
  1. 365
Platform
  1. Windows
hi all

I haven't found anything yet that can help me do what i need. Hoping someone may have the answer.

I have B11 setup with a drop down list of peoples names.
In range D11:IS11 are those same names.

i would like a macro that searches D11:IS11 for the name in B11 and if it is found, hide all other columns.

preference would be that the macro runs from clicking a 'search' button, not by worksheet change event

TIA
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Here is the code you need to attach to a button

Code:
Option Explicit


Sub HideB11()
    Dim i As Long
    Application.ScreenUpdating = False
    For i = 4 To 253
        If Cells(11, i) <> Range("B11") Then
            Cells(11, i).EntireColumn.Hidden = True
        End If
    Next i
    Application.ScreenUpdating = True


End Sub
 
Upvote 0
that is spot on, i appreciate your fast reply.

thank you very much
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top