Range.Select with variable cells ?

L

lance-news

Hello,

I am having a devil of a time trying to find out how to use Range.Select
(or something else) with rows and columns that vary.

row1 = x1
row2 = x2
col1 = y1
col2 = y2

x1=1
x2=2
y1=1
y2=2


Range(R[x1]C[y1]:R[x2]C[y2]).Select

or

Range(R[x1]C[y1+1]:R[x1]C[y2+2]).Select

is what I am trying to accomplish but I keep getting errors.
How do I use the Range statement (or something else) in the
above statements?


Lance
 
R

Ron de Bruin

Try this

Sub test()
x1 = 1
x2 = 2
y1 = 1
y2 = 2

Range(Cells(x1, y1), Cells(x2, y2)).Select
End Sub
 
S

steve

Lance,

Range(Cells(x1,y1),Cells(x2,y2)).Select
or
Range(Cells(x1,y1+1),Cells(x1,y2+2)).Select
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top