ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Defining range (https://www.excelbanter.com/excel-programming/291599-defining-range.html)

Edgar[_3_]

Defining range
 
Hi Experts

What is wrong with the following line of code, it jsut
wont except it.

I am trying to set the range in sheet "Email_Control"

The Range will be all cells in columns a:c with data in
them.


Worksheets("Email_Control").Range("A1:C& Cells
(Rows.Count, 1).Name = "Email_Lookup_Table"

TIA

Bob Phillips[_6_]

Defining range
 
Edgar,

Cells(Rows.Count, 1) will return the value in A65336 (or so). I think you
want the last row, which is

Cells(Rows.Count,"A").End(xlUp).Row
--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Edgar" wrote in message
...
Hi Experts

What is wrong with the following line of code, it jsut
wont except it.

I am trying to set the range in sheet "Email_Control"

The Range will be all cells in columns a:c with data in
them.


Worksheets("Email_Control").Range("A1:C& Cells
(Rows.Count, 1).Name = "Email_Lookup_Table"

TIA




Tom Ogilvy

Defining range
 
You also have a syntax problem
Worksheets("Email_Control").Range("A1:C & _
Cells(Rows.Count, 1).End(xlup).Row).Name = "Email_Lookup_Table"

--
Regards,
Tom Ogilvy


"Edgar" wrote in message
...
Hi Experts

What is wrong with the following line of code, it jsut
wont except it.

I am trying to set the range in sheet "Email_Control"

The Range will be all cells in columns a:c with data in
them.


Worksheets("Email_Control").Range("A1:C& Cells
(Rows.Count, 1).Name = "Email_Lookup_Table"

TIA





All times are GMT +1. The time now is 12:36 PM.

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