View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Kirby[_3_] Kirby[_3_] is offline
external usenet poster
 
Posts: 5
Default 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?