Macro to hide cols

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
 
C

Claus Busch

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
 
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

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top