Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Define Range Name with variable row value


I'm trying to define a name range using variable rows but somehow the
range name does not get calculated.
I currently have this code which works with fixed ranges.

What to do to use variable rows?

'Deploy Formula on both sheets to find data differences
Dim lastrowquery As Integer
Dim lastrowreport As Integer
lastrowquery = Sheets("sheet1").Range("C1").End(xlDown).Row
lastrowreport = Sheets("sheet2").Range("C6").End(xlDown).Row
'Assign Range Names before Formulas
Range("C1:C" & lastrowquery).Select
ActiveWorkbook.Names.Add Name:="rangename", RefersToR1C1:= _
"='sheet1'!R1C3:R348C3"
Sheets("sheet2").Select
Range("J6").Select
ActiveCell.FormulaR1C1 = "=ISNA(MATCH(RC[-7],rangename,FALSE))"
Selection.AutoFill Destination:=Range("J6:J" & lastrowreport),
Type:=xlFillDefault

Suggestions greatly appreciated...

Thanks


--
wayliff
------------------------------------------------------------------------
wayliff's Profile: http://www.excelforum.com/member.php...o&userid=29860
View this thread: http://www.excelforum.com/showthread...hreadid=502040

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Define Range Name with variable row value

Hi,
Try:

ActiveWorkbook.Names.Add Name:="rangename", RefersToR1C1:= _
"='sheet1'!R1C3:R" & lastrowquery & "C3"


HTH

"wayliff" wrote:


I'm trying to define a name range using variable rows but somehow the
range name does not get calculated.
I currently have this code which works with fixed ranges.

What to do to use variable rows?

'Deploy Formula on both sheets to find data differences
Dim lastrowquery As Integer
Dim lastrowreport As Integer
lastrowquery = Sheets("sheet1").Range("C1").End(xlDown).Row
lastrowreport = Sheets("sheet2").Range("C6").End(xlDown).Row
'Assign Range Names before Formulas
Range("C1:C" & lastrowquery).Select
ActiveWorkbook.Names.Add Name:="rangename", RefersToR1C1:= _
"='sheet1'!R1C3:R348C3"
Sheets("sheet2").Select
Range("J6").Select
ActiveCell.FormulaR1C1 = "=ISNA(MATCH(RC[-7],rangename,FALSE))"
Selection.AutoFill Destination:=Range("J6:J" & lastrowreport),
Type:=xlFillDefault

Suggestions greatly appreciated...

Thanks


--
wayliff
------------------------------------------------------------------------
wayliff's Profile: http://www.excelforum.com/member.php...o&userid=29860
View this thread: http://www.excelforum.com/showthread...hreadid=502040


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Define Range Name with variable row value


I feel pretty stupid since I tried that already but was missing one "
quotation.

Thanks for your help...made my hour.


--
wayliff
------------------------------------------------------------------------
wayliff's Profile: http://www.excelforum.com/member.php...o&userid=29860
View this thread: http://www.excelforum.com/showthread...hreadid=502040

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
Define variable range input for SUM() function JeffC Excel Worksheet Functions 4 May 16th 09 03:54 AM
Define Variable Name using VBA GTReferee Excel Discussion (Misc queries) 2 January 21st 09 06:37 PM
How to define variable kishore Excel Programming 3 May 13th 05 10:22 AM
Define Object Variable al Excel Programming 7 October 9th 04 08:03 PM
Define variable range acberry Excel Programming 2 May 12th 04 02:44 PM


All times are GMT +1. The time now is 07:59 AM.

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

About Us

"It's about Microsoft Excel"