Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 468
Default Moving a range name AND Contents

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?

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default Moving a range name AND Contents

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

"JMay" wrote:

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?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 468
Default Moving a range name AND Contents

Thanks for the help Fst1, I got it !!

"FSt1" wrote:

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

"JMay" wrote:

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?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copying and moving column contents along with headings Colin Excel Worksheet Functions 0 November 6th 07 06:49 PM
compare the contents of one range of cells with the contents of a. Dozy123 Excel Discussion (Misc queries) 1 January 24th 07 10:14 AM
sum with moving range snax500 Excel Discussion (Misc queries) 3 July 10th 06 05:56 AM
moving the contents of a cell JenBasch Excel Worksheet Functions 2 September 20th 05 03:16 AM
moving cell contents (automatically) Rusty Excel Discussion (Misc queries) 1 June 15th 05 09:01 PM


All times are GMT +1. The time now is 02:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"