Reference Range Names in Macro

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.
 
K

Karin

I should add that the B17:K17 and b39:k39 are merged cells. Not sure if that
matters.
 
J

Jim Thomlinson

Assuming your named ranges are globally defined then

application.names("Audit1").referstorange.copy _
Destination:=application.names("Note1").referstorange
 
K

Karin

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.
 
J

Jim Thomlinson

If they are locally declared then...

Sheets("Notes").Range("Audit1").Copy Sheets("RouteSlip").Range("Note1")
 
D

Dave Peterson

Merged cells are a pain...

Can you just assign the value?

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

Gord Dibben

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
 
K

Karin

Thank you, but for some reason it doesn't work. However, the answer below
from Dave Peterson does work.
 
K

Karin

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

Top