Macro to hide cols

  • Thread starter Thread starter pcorcele
  • Start date Start date
P

pcorcele

I would like a macro that would allow me to hide col B to the selected col, minus one col(ie If I place the cursor on col F then col B thru E would be hidden or if the cursor is on COL J, the macro would hide Col B to I)
Thanks
 
Hi,

Am Sun, 16 Sep 2012 11:40:22 -0700 (PDT) schrieb pcorcele:
I would like a macro that would allow me to hide col B to the selected col, minus one col(ie If I place the cursor on col F then col B thru E would be hidden or if the cursor is on COL J, the macro would hide Col B to I)

try:

Sub HideCols()
Dim myRow As Long
Dim myAdr As String

myRow = ActiveCell.Row
myAdr = ActiveCell.Offset(0, -1).Address(0, 0)
Range("B" & myRow & ":" & myAdr).EntireColumn.Hidden = True
End Sub


Regards
Claus Busch
 
I would like a macro that would allow me to hide col B to the selected col, minus one col(ie If I place the cursor on col F then col B thru E would be hidden or if the cursor is on COL J, the macro would hide Col B to I)

Thanks

That was just great ...and very quick. Thanks
Ian M
 
Back
Top