multiple selection

  • Thread starter Thread starter Michalll
  • Start date Start date
M

Michalll

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
 
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
 
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)
 
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
 
Back
Top