ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   multiple selection (https://www.excelbanter.com/excel-programming/283968-multiple-selection.html)

Michalll

multiple selection
 
Help me please,

I need make a multiple selection in VBA but vith variable.

My example which works:
range("A1:A2, C1:C2").select

I need something like:
value = 2
range("A1:A & value, C1:C & value").select

but it does not work, would you help me?

thanx

Michal

Chip Pearson[_2_]

multiple selection
 
Michal,

You're close. Try the following:

Dim Value As Long
Value = 2
Range("A1:A" & Value & ",C1:C" & Value).Select


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Michalll" wrote in message
om...
Help me please,

I need make a multiple selection in VBA but vith variable.

My example which works:
range("A1:A2, C1:C2").select

I need something like:
value = 2
range("A1:A & value, C1:C & value").select

but it does not work, would you help me?

thanx

Michal




J.E. McGimpsey

multiple selection
 
one way:

Dim myValue As Long
myValue = 2
Range("A1:A" & myValue & ",C1:C" & myValue).Select

(it's better not to use VBA keywords, like Value as variable names -
it can get very confusing)



In article ,
(Michalll) wrote:

Help me please,

I need make a multiple selection in VBA but vith variable.

My example which works:
range("A1:A2, C1:C2").select

I need something like:
value = 2
range("A1:A & value, C1:C & value").select

but it does not work, would you help me?

thanx

Michal


Dana DeLouis[_3_]

multiple selection
 
If you don't like working with strings, perhaps another option might be
something like this...

n = 2
Intersect([A1,C1,E1,G1].EntireColumn, Rows(1).Resize(n)).Select

--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"Michalll" wrote in message
om...
Help me please,

I need make a multiple selection in VBA but vith variable.

My example which works:
range("A1:A2, C1:C2").select

I need something like:
value = 2
range("A1:A & value, C1:C & value").select

but it does not work, would you help me?

thanx

Michal





All times are GMT +1. The time now is 01:27 AM.

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