Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro that will always hide / unhide next column
Thank you in advance for your help; it is much appreciated. I have a
weekly sales tracking spreadsheet that always shows the current week and previous 3 weeks sales data. Currently I have 52 columns, one for each week. Only the current week and previous 3 weeks are visible, the other columns are hidden. Therefore, there are hidden columns left of the first visible week and hidden columns right of the last visible week. Example: May-12 May-19 May-26 Jun-2 717 711 721 721 92 86 92 92 I have created 2 macros; one that will unhide the colunm to the right of the active cell: ActiveCell.Offset(0, 1).EntireColumn.Hidden = False and one that will hide the column to the left of the active cell: ActiveCell.Offset(1, 0).EntireColumn.Hidden = True My current process involves putting the cursor on the last visible week and executing the unhide macro and then putting the cursor on the second week and executing the hide macro. This is working fine, but is time consuming. Is there a way to create a macro that will always unhide the next hidden column and hide the first unhidden column without putting the cursor in the cells? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro that will always hide / unhide next column
Sub Managecolumns()
Dim i As Long For i = 1 To 52 If Columns(i).Hidden = False Then bfirst = True Columns(i).Hidden = True Columns(i + 4).Hidden = False Exit For End If Next End Sub -- Regards, Tom Ogilvy "Kirby" wrote in message om... Thank you in advance for your help; it is much appreciated. I have a weekly sales tracking spreadsheet that always shows the current week and previous 3 weeks sales data. Currently I have 52 columns, one for each week. Only the current week and previous 3 weeks are visible, the other columns are hidden. Therefore, there are hidden columns left of the first visible week and hidden columns right of the last visible week. Example: May-12 May-19 May-26 Jun-2 717 711 721 721 92 86 92 92 I have created 2 macros; one that will unhide the colunm to the right of the active cell: ActiveCell.Offset(0, 1).EntireColumn.Hidden = False and one that will hide the column to the left of the active cell: ActiveCell.Offset(1, 0).EntireColumn.Hidden = True My current process involves putting the cursor on the last visible week and executing the unhide macro and then putting the cursor on the second week and executing the hide macro. This is working fine, but is time consuming. Is there a way to create a macro that will always unhide the next hidden column and hide the first unhidden column without putting the cursor in the cells? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro that will always hide / unhide next column
Thank you for your code example; it was very helpfull. How would I
manipulate the code to unhide 2 rows instead of one. Here is a reference to the example code: Sub Managecolumns() Dim i As Long For i = 1 To 52 If Columns(i).Hidden = False Then bfirst = True Columns(i).Hidden = True Columns(i + 4).Hidden = False Exit For End If Next End Sub Thank you for your help, Kirby *** Sent via Devdex http://www.devdex.com *** Don't just participate in USENET...get rewarded for it! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I set up a column tool to hide/unhide? | Excel Discussion (Misc queries) | |||
Macro that will unhide then hide rows | Excel Discussion (Misc queries) | |||
Check Box Macro to hide and unhide a column | Excel Worksheet Functions | |||
hide/unhide macro | Excel Discussion (Misc queries) | |||
Hide/Unhide Macro bug | Excel Programming |