Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Copying a Name's Contents

Garry,

The macro below runs without error:

Dim rngSource As Range, rngTarget As Range
Set rngSource = Workbooks("Book1.xlsb").Sheets("Sheet1").Range("Na me1")
Set rngTarget = Workbooks("Book2.xlsb").Sheets("Sheet1").Range("A1 ")
rngTarget.Resize(rngSource.Rows.Count, 1).Value = rngSource

However, after the macro runs, the contents of A1:A3 in Book2.xlsb is
empty.


kittronald


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Copying a Name's Contents

Garry,

The process works when I use the code below:

Windows("Book1.xlsb").Activate
Application.Goto Reference:="Name1"
Selection.Copy
Windows("Book2.xlsb").Activate
Range("A1").Select
ActiveSheet.Paste

I was wondering if there was a shorter, more elegant way to get the same
result.


kittronald


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default Copying a Name's Contents

modify to suit


Sub copynamedrange()
Range("rng1").Copy Sheets("sheet4").Range("h21")
End Sub



On Sunday, March 11, 2012 7:04:39 AM UTC-5, kittronald wrote:
Garry,

The process works when I use the code below:

Windows("Book1.xlsb").Activate
Application.Goto Reference:="Name1"
Selection.Copy
Windows("Book2.xlsb").Activate
Range("A1").Select
ActiveSheet.Paste

I was wondering if there was a shorter, more elegant way to get the same
result.


kittronald


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Copying a Name's Contents

Don,

Thanks for the reply.

However, I'm not getting it to work between workbooks.


kittronald


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Copying a Name's Contents

For now, the code is working as follows:

Workbooks("Book1.xlsb").Sheets("Sheet1").Range("Na me1").Copy
Workbooks("Book2.xlsb").Sheets("Sheet1").Range("A1 ").PasteSpecial
Workbooks("Book2.xlsb").Names.Add Name:="Name1",
RefersTo:=Sheets("Sheet1").Range("A1:A3")

Thanks for all the help.


kittronald


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
Modifying a Defined Name's Contents kittronald Excel Programming 10 October 5th 11 02:19 PM
Put Name's Refer's to: field in cell kittronald Excel Programming 21 October 5th 11 03:42 AM
Is there a way to place the cell contents separated by a comma byinserting a new line and then copying the contents anshu minocha Excel Programming 1 January 29th 10 11:51 PM
Is there a way to place the cell contents separated by a comma byinserting a new line and then copying the contents anshu minocha Excel Programming 0 January 26th 10 07:29 PM
How to Print Name's list and Names Range? Excel_Oz Excel Worksheet Functions 3 March 29th 07 02:03 AM


All times are GMT +1. The time now is 04:03 AM.

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

About Us

"It's about Microsoft Excel"