View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Macro to hide cols

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
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2