Variable usage in Range Command

D

DavidC

Help please

When using the Range("B1:B50").Select I want to
substitute a variable into the Range.

I have a variable which is a number e.g test=50

Therefore the command I want is
Range(B1:B'test'").Select

I cannot get the syntax right.

Idea is to select a range of data based on variables.
Is this the right way?

Cheers
David
 
D

David Benson

David,

Since the argument of the Range object is a string, you can manipulate it
just as you would any other string:

TestRng = "B1:B"&test
Range(TestRng)

or just

Range("B1:B"&test)

Good luck!

-- David
 
Top