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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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
 
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top