Try this:
![]()
Sub HideCols() Dim cell As Range Dim lcol As Integer lcol = ActiveSheet.UsedRange.Columns.Count For Each cell In Range(Cells(1, 1), Cells(1, lcol)) If cell.Value < Date Then cell.EntireColumn.Hidden = True Next End Sub
Try this:
![]()
Sub HideCols() Dim cell As Range Dim lcol As Integer lcol = ActiveSheet.UsedRange.Columns.Count For Each cell In Range(Cells(1, 1), Cells(1, lcol)) If cell.Value < Date Then cell.EntireColumn.Hidden = True Next End Sub
Regards,
Stephen
If you feel someone has helped you please thank them and click on the star on their post to add reputation.
Please ensure that you use code tags where relevant, and mark solved threads as solved.
Most of all please be respectful and understanding of others.
Thanks Stephen! Works pretty good!
I don't want it to hide column A though, so how do I modify?'
And, where do I put this code so that it automatically updates when the file/sheet is opened? Right now I've put it under a new module and manually running the module in the VBA application.
Thanks Stephen! Works pretty good!
I don't want it to hide column A though, so how do I modify?'
And, where do I put this code so that it automatically updates when the file/sheet is opened? Right now I've put it under a new module and manually running the module in the VBA application.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks