Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid Reference Error when calling named Range 1

Status
Not open for further replies.

Mantle51

Programmer
Aug 17, 2006
97
US
Hello,
I've created the following named range in code, however, it will not appear in the name box and when trying to select/copy/paste using GoTo method I get the above referenced.....Thanks

Dim FinalRow As Long
FinalRow = Cells(Rows.Count, 2).End(xlUp).Row

ActiveWorkbook.Names.Add Name:="NEW", RefersToR1C1:= _
"=Sheet1!R1C10:R & FinalRow & C10,Sheet1!R1C18:R & FinalRow & C18"
Application.Goto Reference:="NEW"

Selection.Copy
Sheets.Add
ActiveSheet.Paste
 

Your formula needs a couple more quotes to allow proper concatenation for the result you want:

Code:
Dim FinalRow As Long
FinalRow = Cells(Rows.Count, 2).End(xlUp).Row
    
    ActiveWorkbook.Names.Add Name:="NEW", RefersToR1C1:= _
        "=Sheet1!R1C10:R" & FinalRow & "C10,Sheet1!R1C18:R" & FinalRow & "C18"
    Application.Goto Reference:="NEW"
    
    Selection.Copy
    Sheets.Add
    ActiveSheet.Paste
 
Oh man, why does simple syntax absolutely murder me?!!

Thank you very much....Mick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top