Moving a range name AND Contents

J

JMay

Currently MyRng (a named range) refersto: sheet1 - B2:D4

How can I change that in VBA to sheet2 - D5 (D5:F7)?

I wish to also include the cells B2:D4 values/contents.

How is this done?
 
F

FSt1

hi
something like this might work.
note your destination range is larger than your source range?????
Sub MoveNamedRange()
Dim r As Range
Set r = Range("MyRng")
Range("MyRng").Copy Destination:= _
Sheets("Sheet2").Range("D5:F7")
ActiveWorkbook.Names.Add Name:="MyRng", _
RefersTo:=Sheets("Sheet2").Range("D5:F7")
r.ClearContents 'optional
End Sub

Regards
FSt1
 
J

JMay

Thanks for the help Fst1, I got it !!

FSt1 said:
hi
something like this might work.
note your destination range is larger than your source range?????
Sub MoveNamedRange()
Dim r As Range
Set r = Range("MyRng")
Range("MyRng").Copy Destination:= _
Sheets("Sheet2").Range("D5:F7")
ActiveWorkbook.Names.Add Name:="MyRng", _
RefersTo:=Sheets("Sheet2").Range("D5:F7")
r.ClearContents 'optional
End Sub

Regards
FSt1
 

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