ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selecting Multiple Columns (https://www.excelbanter.com/excel-programming/279422-selecting-multiple-columns.html)

Jay[_12_]

Selecting Multiple Columns
 
How can I select multiple columns in Excel using VBA when
the number of columns is a variable? I have a variable
that tells me how many columns to select. How can I make
VB select the number of columns (for hiding) based on the
variable that I have?

Jay

Ron de Bruin

Selecting Multiple Columns
 
Try this Jay

Sub test()
Dim var As Integer
var = 3
Columns(ActiveCell.Column).Resize(, var).Hidden = True
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Jay" wrote in message ...
How can I select multiple columns in Excel using VBA when
the number of columns is a variable? I have a variable
that tells me how many columns to select. How can I make
VB select the number of columns (for hiding) based on the
variable that I have?

Jay





All times are GMT +1. The time now is 06:07 PM.

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