Reference Range Names in Macro

  • Thread starter Thread starter Karin
  • Start date Start date
K

Karin

Hi, This works:

Sheets("Notes").Range("b17:K17").Copy Sheets("RouteSlip").Range("B39:K39")

But I was hoping to use range names instead of cell references and I can't
make it work.

Range b17:K17 = Audit1
Range b39:k39 = Note1

Thank you.
 
Assuming your named ranges are globally defined then

application.names("Audit1").referstorange.copy _
Destination:=application.names("Note1").referstorange
 
Hi, Jim, thank you.
It didn't work, perhaps I'm not globally defined - ranges were named in the
name box, sheet that Audit1 is on is hidden.
 
If they are locally declared then...

Sheets("Notes").Range("Audit1").Copy Sheets("RouteSlip").Range("Note1")
 
Merged cells are a pain...

Can you just assign the value?

WorkSheets("RouteSlip").Range("Note1").Value _
= WorkSheets("Notes").Range("Audit1")
 
The named ranges are defined currently?

Audit1 refers to =Notes!$B$17:$K$17

Notel refers to =RouteSlip!$B$39:$K$39

No need to paste to a range.

Top left cell only will do.

Sheets("Notes").Range("Audit1").Copy Sheets("RouteSlip").Range("B39")

But you can use "Notel" if you want to.


Gord Dibben MS Excel MVP
 
Thank you, but for some reason it doesn't work. However, the answer below
from Dave Peterson does work.
 
Thank you -works great.


Dave Peterson said:
Merged cells are a pain...

Can you just assign the value?

WorkSheets("RouteSlip").Range("Note1").Value _
= WorkSheets("Notes").Range("Audit1")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top