How to hide pre-defined columns at the touch of a button

P

Paresh

Scenario:
I have multiple spreadsheets which have predefined columns (i.e. Product, Price, Quantity, Total)
I wish to be able to hide predefined columns (i.e. Product and Total)
Ideally it should be in the form of a macro with a button on the toolbar (or an added menu item) so that I can apply it to spreadsheets which I load

Any ideas would be greatly appreciated
 
B

Bernie Deitrick

Paresh,

If you only have Total and Product appearing once, then copy this macro into
your personal.xls and assign it to a commandbar button:

Sub HideTotalProduct()
Cells.Find(What:="Total", _
LookAt:=xlWhole).EntireColumn.Hidden = True
Cells.Find(What:="Product", _
LookAt:=xlWhole).EntireColumn.Hidden = True
End Sub

HTH,
Bernie
MS Excel MVP

Paresh said:
Scenario:
I have multiple spreadsheets which have predefined columns (i.e. Product, Price, Quantity, Total)
I wish to be able to hide predefined columns (i.e. Product and Total)
Ideally it should be in the form of a macro with a button on the toolbar
(or an added menu item) so that I can apply it to spreadsheets which I load
 
P

Paresh

Bernie

Thank you for your suggestion. It seems to do the trick. My question though is what is 'personal.xls'? How do I write this code such that the function is available at all times for any spreadsheet I load

Paresh
 
B

Bernie Deitrick

Paresh,

Personal.xls is a macro library. To create one, turn on the macro recorder,
and when prompted as to where to save the macro, choose "Personal Macro
Workbook" Then click Ok, click the stop button, then go into the VBE using
Alt-F11, and your personal.xls will be available there for you to store
macros in and have them available every time you open Excel.

HTH,
Bernie
MS Excel MVP

Paresh said:
Bernie,

Thank you for your suggestion. It seems to do the trick. My question
though is what is 'personal.xls'? How do I write this code such that the
function is available at all times for any spreadsheet I load?
 
Top