This gives you a simple method to hide columns based on the active cell.
It looks at row 6 of the column of the active cell to determine the year and then, starting at column H finds the first incidence of that year.
This is easily adapted. The trick is the little loop and what is fed into it as the variable "myyear"
The value of variable "col" when the loop has finished minus 1, is the last column number of the previous year
Sub HideColumns()
'Hide columns based on active cell
myyear = Year(Cells(6, ActiveCell.Column))
answer = MsgBox("I want to hide columns prior to year " & myyear, vbYesNo)
If answer <> vbYes Then Exit Sub
col = 7
Do Until x = myyear
col = col + 1
x = Year(Cells(6, col))
Loop
MsgBox "hide all columns between " & Cells(1, 8).Address(0, 0) & " and " & Cells(1, col - 1).Address(0, 0), vbYesNo
If answer <> vbYes Then Exit Sub
Range(Cells(1, 8), Cells(1, col - 1)).Columns.EntireColumn.Hidden = True
End Sub
Bookmarks