ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   select columns by variable (https://www.excelbanter.com/excel-programming/346880-select-columns-variable.html)

jack

select columns by variable
 
Is there something in vba that will allow me to select a certain amount of
columns by variable?

I have a sum that is formulated on sheet1. I need to figure out how to
select that many columns starting at b1 on sheet 2. If it matters I need to
have 5 rows by ever how many columns.

thanks so much for your help!

Bob Phillips[_6_]

select columns by variable
 


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jack" wrote in message
...
Is there something in vba that will allow me to select a certain amount of
columns by variable?

I have a sum that is formulated on sheet1. I need to figure out how to
select that many columns starting at b1 on sheet 2. If it matters I need

to
have 5 rows by ever how many columns.

thanks so much for your help!




Bob Phillips[_6_]

select columns by variable
 

myVar =5
Worksheets("Sheet2").Range("B1).Resize(1,myVar).En tireColumn.Select

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jack" wrote in message
...
Is there something in vba that will allow me to select a certain amount of
columns by variable?

I have a sum that is formulated on sheet1. I need to figure out how to
select that many columns starting at b1 on sheet 2. If it matters I need

to
have 5 rows by ever how many columns.

thanks so much for your help!




L. Howard Kittle

select columns by variable
 
Hi Jack,

Sub ColsandRows()
Dim i As Integer
i = Range("A1").Value
Range("B2").Resize(5, i).Select
End Sub

HTH
Regards,
Howard

"Jack" wrote in message
...
Is there something in vba that will allow me to select a certain amount of
columns by variable?

I have a sum that is formulated on sheet1. I need to figure out how to
select that many columns starting at b1 on sheet 2. If it matters I need
to
have 5 rows by ever how many columns.

thanks so much for your help!




Norman Jones

select columns by variable
 
Hi Jack,

Try:

'<<=============
Sub Tester02()
Dim i As Long
i = Sheets("Sheet1").Range("A1").Value '<<==== CHANGE

With Sheets("Sheet2")
.Activate
.Range("B2").Resize(5, i).Select
End With
End Sub
'<<=============

Note, however, that it is rarely necessary or desirable to make selections

---
Regards,
Norman



"Jack" wrote in message
...
Is there something in vba that will allow me to select a certain amount of
columns by variable?

I have a sum that is formulated on sheet1. I need to figure out how to
select that many columns starting at b1 on sheet 2. If it matters I need
to
have 5 rows by ever how many columns.

thanks so much for your help!





All times are GMT +1. The time now is 08:45 AM.

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