Selecting/copying a dynamic range in VB

J

Josip

Hello,

this might be a fairly simple question, but if somebody could help out
I would greatly appreciate it.
So, my problem is that I want to copy a ceratin range from a
worksheet. However, this range is dynamic and depends on three values:

1. The "coordinates" of the data, i.e. the location of the top-left
cell
2. The width of the table/selection
3. The lenght of the table/selection

If I have these values in cells A1, A2, A3, A4. How do I code the
selection into VB? .Range( ??? )
Moreover, how do I use OFFSET in this kind of range selection
situation?


BR,
Josip
 
R

Rick Rothstein

Assuming A1 has the row number, A2 has the column number, A3 has the number
of rows deep and A4 has the number of column wide...

Set R = Cells(Range("A1"), Range("A2")).Resize(Range("A3"), Range("A4"))

where R is Dim'med as a Range. After doing this, R will be a real range that
you can do whatever you want to, including Offset'ting from if desired.
 

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