ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to hide cols (https://www.excelbanter.com/excel-programming/447138-macro-hide-cols.html)

pcorcele

Macro to hide cols
 
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

Claus Busch

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

pcorcele

Macro to hide cols
 
On Sunday, 16 September 2012 14:40:22 UTC-4, pcorcele wrote:
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


All times are GMT +1. The time now is 02:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com