ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to hide pre-defined columns at the touch of a button (https://www.excelbanter.com/excel-programming/297540-how-hide-pre-defined-columns-touch-button.html)

Paresh

How to hide pre-defined columns at the touch of a button
 
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

Bernie Deitrick

How to hide pre-defined columns at the touch of a button
 
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" wrote in message
...
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

How to hide pre-defined columns at the touch of a button
 
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

Bernie Deitrick

How to hide pre-defined columns at the touch of a button
 
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" wrote in message
...
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





All times are GMT +1. The time now is 06:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com