Unhide Columns one at a time

Partjob

Board Regular
Joined
Apr 17, 2008
Messages
139
Hello
I would like to be able to Unhide columns that have been hidden by a different macro one at a time.

I have a sheet that has dates at the top of each column starting at column H (Jan 08) this can theoretically go all the way to Column IV. I already have some code that hides any column with a date older than 3 months. Eg Today is August 08 so all columns from Jan 08 to May 08 hide. As it hides a column, it adds a column to the end so I have 4 years of dates on show at any one time. I don't think this code its self is important at this time so I have not posted it.

There has come the need to review old information in the hidden columns so I wrote this code that is executed on a command button to unhide the hidden columns.
Code:
Public Sub StopHideCol()
Sheet2.Cells(61, 6) = "x"
ActiveSheet.Columns("G:IV").Hidden = False
End Sub
It doesn't really get any simpler than that. The command button just calls this macro as I have several buttons all doing the same thing on different sheets. The x being written to the cell is so I can stop the hide column macro firing until the workbook is closed.

Instead of unhiding all the hidden columns I would just like to unhide 1 at a time starting with the closest month in time and moving back at each press of the Command Button. This is because as time goes by more and more columns will be hidden and this seems a logical way to mange how many columns are showing.

Thanks as usual for any advise and help recieved.
Partjob
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hi This code wil unhide the Furthest column (Latest Date), each time you
click the Button.
Code:
Dim col As Integer, CNo As Integer
For col = 1 To Columns.Count
    If Columns(col).Hidden = True Then
        CNo = col
    End If
 Next col
 If CNo > 0 Then
 Columns(CNo).Hidden = False
End If
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,215,757
Messages
6,126,694
Members
449,331
Latest member
smckenzie2016

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top