Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
HIDING A VARIABLE NUMBER OF COLUMNS
I have a spreadsheet with 12 columns of numbers preceded by one column
with labels. I want to use the same spreadsheet for each month of data and just hide the blank columns. Since it is February, I want to hide the columns for March through December (D through M) since they will be blank. Next month I only want to hide April through December, etc. How can I add a dialog box where I enter the number of the month (in this case 2) and it hides the rest of the months. Or alternatively, if I tell it how many columns to hide, it can start at column M and work backwards. Thanks, Columns("D:M").Select Range("D1").Activate Selection.EntireColumn.Hidden = True |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
HIDING A VARIABLE NUMBER OF COLUMNS
How about something like
Sub HideColumns() MonthVar = 7 ActiveSheet.Range("B1").Offset(0, MonthVar).Resize(1, 12 - MonthVar).EntireColumn.Hidden = True End Sub I just rezise the range by subtracting the variable from 12 and hide those columns Of course you can set an inputbox to the variable or just pull from the current date David " wrote: I have a spreadsheet with 12 columns of numbers preceded by one column with labels. I want to use the same spreadsheet for each month of data and just hide the blank columns. Since it is February, I want to hide the columns for March through December (D through M) since they will be blank. Next month I only want to hide April through December, etc. How can I add a dialog box where I enter the number of the month (in this case 2) and it hides the rest of the months. Or alternatively, if I tell it how many columns to hide, it can start at column M and work backwards. Thanks, Columns("D:M").Select Range("D1").Activate Selection.EntireColumn.Hidden = True |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Adding variable number of columns | Excel Worksheet Functions | |||
sum number of columns based on variable value | Excel Discussion (Misc queries) | |||
adding variable number of columns | Excel Worksheet Functions | |||
Chart based on variable number of columns | Charts and Charting in Excel | |||
deleting a variable number of columns | Excel Programming |