Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I set up a column tool to hide/unhide? pufimic Excel Discussion (Misc queries) 1 October 27th 06 01:26 AM
Macro that will unhide then hide rows minka Excel Discussion (Misc queries) 10 October 21st 06 01:37 PM
Check Box Macro to hide and unhide a column Daphne Excel Worksheet Functions 9 June 26th 06 01:50 PM
hide/unhide macro Matt Excel Discussion (Misc queries) 2 April 6th 06 07:24 PM
Hide/Unhide Macro bug Dave[_28_] Excel Programming 1 September 4th 03 06:26 PM


All times are GMT +1. The time now is 07:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"