Select range using row and column number addresses

N

NDBC

I'm trying to select a range starting in a1 and finishing at a known row and
column number. I have tried this but am getting an error. Arow is the number
of rows down and MAxa is the number of columns across.

wb.Sheets("A Lap").Range("a1:" & Cells(ARow, MaxA)).Copy
wbNew.Sheets("Sheet1").Range("A1")

I'm guessing either cells is the wrong command or i'm using it incorrectly.
Thanks
 
N

NDBC

I've done it now.

For those interested

wb.Sheets("A Lap").Range("a1:" & Cells(ARow, MaxA).Address).Copy
 
J

Jacob Skaria

Good... It is a bit more easier...

--When you work with column numbers and row numbers try
Range(Cells(r1,c1), Cells(r2,c2))
where r1,c1,r2,c2 are numbers

--When you work with row numbers try Range("A1","J10") OR Range("A1:J10")
Range("A" & r1 & ":J" & r2)
Range("A" & r1 , "J" & r2)
where r1 and r2 are row numbers and A and J are column names or you can
replace those with string variables.

OR

Range(Cells(r1,"A"),Cells(r2,"J")) where r1 and r2 are row numbers and A and
J are column names or you can replace those with string variables.

If this post helps click Yes
 
J

Jacob Skaria

In your case the below should work

Range("A1" , Cells(ARow, MaxA)).Copy

If this post helps click Yes
 
N

NDBC

Thanks for explaining the differences to me. Makes it a lot easier to
understand so I don't have to muddle my way through.
 

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