ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can't copy named range (https://www.excelbanter.com/excel-programming/374121-cant-copy-named-range.html)

[email protected]

Can't copy named range
 
Why will this work.....
Sheets("Configuration").Range("J35:Q35").Copy
Workbooks(HomeBook).Sheets("Report").Range("B" & LastRow)

but not this.....

Sheets("Configuration").Range(MyNamed Range).Copy
Workbooks(HomeBook).Sheets("Report").Range("B" & LastRow)

can't seem to reference a named range in the copy line? Any help
appreciated.


Don Guillett

Can't copy named range
 
change name and use
Range("MyNamed_Range").Copy


--
Don Guillett
SalesAid Software

wrote in message
oups.com...
Why will this work.....
Sheets("Configuration").Range("J35:Q35").Copy
Workbooks(HomeBook).Sheets("Report").Range("B" & LastRow)

but not this.....

Sheets("Configuration").Range(MyNamed Range).Copy
Workbooks(HomeBook).Sheets("Report").Range("B" & LastRow)

can't seem to reference a named range in the copy line? Any help
appreciated.




venkat

Can't copy named range
 


" wrote:

Why will this work.....
Sheets("Configuration").Range("J35:Q35").Copy
Workbooks(HomeBook).Sheets("Report").Range("B" & LastRow)

but not this.....

Sheets("Configuration").Range(MyNamed Range).Copy
Workbooks(HomeBook).Sheets("Report").Range("B" & LastRow)

can't seem to reference a named range in the copy line? Any help
appreciated.




Is mynamedrange a variable within the macro or the string name of the range
in the spreadsheet. If it is latter try to type
range("mynameddrange")

if you use this a varaibe use like this
dim mynamedrange as string
set mynamedrange=range("J35:Q35")
then
mynamedrange.copy ..............

try soemthing on thee lines.

kounoike[_2_]

Can't copy named range
 
I think Range("MyNamed Range"), not Range(MyNamed Range), so in my thought

Range("MyNamed Range").Copy
Workbooks(HomeBook).Sheets("Report").Range("B" & LastRow)
or
ActiveWorkbook.Range("MyNamed Range").Copy
Workbooks(HomeBook).Sheets("Report").Range("B" & LastRow)

would work.

keizi

wrote in message
oups.com...
Why will this work.....
Sheets("Configuration").Range("J35:Q35").Copy
Workbooks(HomeBook).Sheets("Report").Range("B" & LastRow)

but not this.....

Sheets("Configuration").Range(MyNamed Range).Copy
Workbooks(HomeBook).Sheets("Report").Range("B" & LastRow)

can't seem to reference a named range in the copy line? Any help
appreciated.



[email protected]

Can't copy named range
 


wrote in message
oups.com...
Why will this work.....
Sheets("Configuration").Range("J35:Q35").Copy
Workbooks(HomeBook).Sheets("Report").Range("B" & LastRow)

but not this.....

Sheets("Configuration").Range(MyNamed Range).Copy
Workbooks(HomeBook).Sheets("Report").Range("B" & LastRow)

can't seem to reference a named range in the copy line? Any help
appreciated.


Thanks Venkat,Don & Kounoike you were all right I needed to encase the
named range in speech marks......I was having a bad macro day must stop
eating those fish!



All times are GMT +1. The time now is 02:30 PM.

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