ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Referencing range in another worksheet (https://www.excelbanter.com/excel-programming/421200-referencing-range-another-worksheet.html)

gtslabs

Referencing range in another worksheet
 
I am trying to reference all the values in in column A in a different
worksheet.
I get errors using this. Please advise on the correct syntax.

Set AllCells = Worksheets("Data").Range("a2", Cells(Rows.Count,
"a").End(xlUp))

JLGWhiz

Referencing range in another worksheet
 
Try this:

Set AllCells = Worksheets("Data").Range("a2", Cells(Rows.Count,
"a").End(xlUp).Address)


"gtslabs" wrote:

I am trying to reference all the values in in column A in a different
worksheet.
I get errors using this. Please advise on the correct syntax.

Set AllCells = Worksheets("Data").Range("a2", Cells(Rows.Count,
"a").End(xlUp))


gtslabs

Referencing range in another worksheet
 
On Dec 11, 9:19*pm, JLGWhiz wrote:
Try this:

Set AllCells = Worksheets("Data").Range("a2", Cells(Rows.Count,
"a").End(xlUp).Address)



"gtslabs" wrote:
I am trying to reference all the values in in column A in a different
worksheet.
I get errors using this. *Please advise on the correct syntax.


Set AllCells = Worksheets("Data").Range("a2", Cells(Rows.Count,
"a").End(xlUp))- Hide quoted text -


- Show quoted text -


it only got 2 of the 17 cells that currently have data.

JLGWhiz

Referencing range in another worksheet
 
If that throws an error then try this:

Set AllCells = Worksheets("Data").Range("a2:" & Cells(Rows.Count,
"a").End(xlUp).Address)


"gtslabs" wrote:

I am trying to reference all the values in in column A in a different
worksheet.
I get errors using this. Please advise on the correct syntax.

Set AllCells = Worksheets("Data").Range("a2", Cells(Rows.Count,
"a").End(xlUp))


gtslabs

Referencing range in another worksheet
 
On Dec 11, 9:31*pm, JLGWhiz wrote:
If that throws an error then try this:

Set AllCells = Worksheets("Data").Range("a2:" & Cells(Rows.Count,
"a").End(xlUp).Address)



"gtslabs" wrote:
I am trying to reference all the values in in column A in a different
worksheet.
I get errors using this. *Please advise on the correct syntax.


Set AllCells = Worksheets("Data").Range("a2", Cells(Rows.Count,
"a").End(xlUp))- Hide quoted text -


- Show quoted text -


same 2 cells returned

Dave Peterson

Referencing range in another worksheet
 
dim AllCells as range
with worksheets("Data")
set allcells = .range("a2",.cells(.rows.count,"A").end(xlup))
end with

msgbox allcells.address



gtslabs wrote:

I am trying to reference all the values in in column A in a different
worksheet.
I get errors using this. Please advise on the correct syntax.

Set AllCells = Worksheets("Data").Range("a2", Cells(Rows.Count,
"a").End(xlUp))


--

Dave Peterson

gtslabs

Referencing range in another worksheet
 
On Dec 11, 9:46*pm, Dave Peterson wrote:
dim AllCells as range
with worksheets("Data")
* set allcells = .range("a2",.cells(.rows.count,"A").end(xlup))
end with

msgbox allcells.address

gtslabs wrote:

I am trying to reference all the values in in column A in a different
worksheet.
I get errors using this. *Please advise on the correct syntax.


Set AllCells = Worksheets("Data").Range("a2", Cells(Rows.Count,
"a").End(xlUp))


--

Dave Peterson


Yes, that worked - Thank you all


All times are GMT +1. The time now is 06:27 AM.

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