ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Select range using row and column number addresses (https://www.excelbanter.com/excel-discussion-misc-queries/237639-select-range-using-row-column-number-addresses.html)

NDBC

Select range using row and column number addresses
 
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

NDBC

Select range using row and column number addresses
 
I've done it now.

For those interested

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



"NDBC" wrote:

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


Jacob Skaria

Select range using row and column number addresses
 
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
---------------
Jacob Skaria


"NDBC" wrote:

I've done it now.

For those interested

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



"NDBC" wrote:

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


Jacob Skaria

Select range using row and column number addresses
 
In your case the below should work

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

If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

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
---------------
Jacob Skaria


"NDBC" wrote:

I've done it now.

For those interested

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



"NDBC" wrote:

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


NDBC

Select range using row and column number addresses
 
Thanks for explaining the differences to me. Makes it a lot easier to
understand so I don't have to muddle my way through.

"Jacob Skaria" wrote:

In your case the below should work

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

If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

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
---------------
Jacob Skaria


"NDBC" wrote:

I've done it now.

For those interested

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


"NDBC" wrote:

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



All times are GMT +1. The time now is 01:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com