#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Range Name

I have the following code in my macro:

ActiveWorkbook.Names.Add Name:="Range", RefersToR1C1:= _
"='Sheet1'!R7C1:R125C1"

The problem is the last row of the range will change each
time I run the macro. I have tried finding the last row
of the range and using a variable like this:

ActiveWorkbook.Names.Add Name:="Range", RefersToR1C1:= _
"='AR List'!R7C1:R(lstrow)C1"

But there is something wrong with the syntax because that
isn't correct either.

Any suggestions or ideas would be appreciated. Thanks for
the help........
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Range Name

"JT" wrote in message
...
: I have the following code in my macro:
:
: ActiveWorkbook.Names.Add Name:="Range", RefersToR1C1:= _
: "='Sheet1'!R7C1:R125C1"
:
: The problem is the last row of the range will change each
: time I run the macro. I have tried finding the last row
: of the range and using a variable like this:
:
: ActiveWorkbook.Names.Add Name:="Range", RefersToR1C1:= _
: "='AR List'!R7C1:R(lstrow)C1"
<snip

you can't put a variable in the middle of a string.
"='AR List'!R7C1:R" & lstrow & "C1"

Paul D


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Range Name

Worksheets("AR List").Range("A7:A" & lstrow).Name = "Range"

--

HTH

RP
(remove nothere from the email address if mailing direct)


"JT" wrote in message
...
I have the following code in my macro:

ActiveWorkbook.Names.Add Name:="Range", RefersToR1C1:= _
"='Sheet1'!R7C1:R125C1"

The problem is the last row of the range will change each
time I run the macro. I have tried finding the last row
of the range and using a variable like this:

ActiveWorkbook.Names.Add Name:="Range", RefersToR1C1:= _
"='AR List'!R7C1:R(lstrow)C1"

But there is something wrong with the syntax because that
isn't correct either.

Any suggestions or ideas would be appreciated. Thanks for
the help........



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I enter formula sum(range+range)*0.15 sumif(range=3) tkw Excel Discussion (Misc queries) 2 October 1st 09 09:17 PM
Cond. Format Data Bars of range based on values of another range alexmo Excel Worksheet Functions 4 January 16th 09 04:03 AM
Excel Addin:Setting the range to the Excel.Range object range prop Rp007 Excel Worksheet Functions 5 November 24th 06 04:30 PM
Range.Find returns cell outside of range when range set to single cell Frank Jones Excel Programming 12 June 10th 04 04:22 AM
how to? set my range= my UDF argument (range vs. value in range) [advanced?] Keith R[_3_] Excel Programming 2 August 11th 03 05:55 PM


All times are GMT +1. The time now is 02:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"