store variable
The selecting is not necessary, just state your start point in the code, I
had use A1. Try
Sub HideCols()
Dim iLastCol As Long
Dim iStartCol As Long
iLastCol = Cells(6, Columns.Count).End(xlToLeft).Column
iStartCol = iLastCol - 12
With Columns(iStartCol).Resize(, 6)
.Hidden = Not .Hidden
End With
End Sub
--
HTH
Bob Phillips
(remove nothere from email address if mailing direct)
"Bob Phillips" wrote in message
...
Sub HideCols()
Dim iLastCol As Long
Dim iStartCol As Long
iLastCol = Cells(1, Columns.Count).End(xlToLeft).Column
iStartCol = iLastCol - 12
With Columns(iStartCol).Resize(, 6)
.Hidden = Not .Hidden
End With
End Sub
--
HTH
Bob Phillips
(remove nothere from email address if mailing direct)
"keen learner" wrote in message
...
Assistance Please
jan feb mar apr may june july aug sep oct nov dec 12
mth
Bakkies 5 9 56 45 34 13 87 90 54 34 34 54
519
cars 7 8 23 34 76 9 19 23 35 56 38
34
467
trucks 23 56 67 45 76 32 54 23 56 23 54 54
762
I have a excell spreadsheet setup as above and every month i add a new
colum
I would like to write a macro that can enable me to display 6 month data
and
12 months data alternately or in other words hide and unhide unnecssary
colums
Please help
|