Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ll ll is offline
external usenet poster
 
Posts: 67
Default Copying Range Names to another open workbook

Hi,
I am trying to copy my range names to another open workbook. I've
been looking at the script below but can't figure out how to get it to
copy the range names from the first (LOldWb) workbook to the second
(LNewWb) workbook. Thanks, Louis
-------------------------

'Define old and new workbooks
Workbooks.Open Filename:=UserForm1.TextBox1.Value
LOldWb = ActiveWorkbook.Name

Workbooks.Add
LNewWb = ActiveWorkbook.Name


'Loop to copy range names from old to new workbooks

For Each x In LOldWb.Names

Workbooks(LNewWb).Names.Add Name:=x.Name, _
RefersTo:=x.Value
Next x

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Copying Range Names to another open workbook

II,

give this a try:

'Define old and new workbooks
Dim LOldWb As Workbook
Dim LNewWb As Workbook
Dim x As Name

Set LOldWb = Workbooks.Open(Filename:=UserForm1.TextBox1.Value)
Set LNewWb = Workbooks.Add

'Loop to copy range names from old to new workbooks
For Each x In LOldWb.Names
LNewWb.Names.Add Name:=x.Name, _
RefersTo:=x.RefersTo
Next x



--
Hope that helps.

Vergel Adriano


"ll" wrote:

Hi,
I am trying to copy my range names to another open workbook. I've
been looking at the script below but can't figure out how to get it to
copy the range names from the first (LOldWb) workbook to the second
(LNewWb) workbook. Thanks, Louis
-------------------------

'Define old and new workbooks
Workbooks.Open Filename:=UserForm1.TextBox1.Value
LOldWb = ActiveWorkbook.Name

Workbooks.Add
LNewWb = ActiveWorkbook.Name


'Loop to copy range names from old to new workbooks

For Each x In LOldWb.Names

Workbooks(LNewWb).Names.Add Name:=x.Name, _
RefersTo:=x.Value
Next x


  #3   Report Post  
Posted to microsoft.public.excel.programming
ll ll is offline
external usenet poster
 
Posts: 67
Default Copying Range Names to another open workbook

On Apr 27, 12:10 pm, Vergel Adriano
wrote:
II,

give this a try:

'Define old and new workbooks
Dim LOldWb As Workbook
Dim LNewWb As Workbook
Dim x As Name

Set LOldWb = Workbooks.Open(Filename:=UserForm1.TextBox1.Value)
Set LNewWb = Workbooks.Add

'Loop to copy range names from old to new workbooks
For Each x In LOldWb.Names
LNewWb.Names.Add Name:=x.Name, _
RefersTo:=x.RefersTo
Next x

--
Hope that helps.

Vergel Adriano

"ll" wrote:
Hi,
I am trying to copy my range names to another open workbook. I've
been looking at the script below but can't figure out how to get it to
copy the range names from the first (LOldWb) workbook to the second
(LNewWb) workbook. Thanks, Louis
-------------------------


'Define old and new workbooks
Workbooks.Open Filename:=UserForm1.TextBox1.Value
LOldWb = ActiveWorkbook.Name


Workbooks.Add
LNewWb = ActiveWorkbook.Name


'Loop to copy range names from old to new workbooks


For Each x In LOldWb.Names


Workbooks(LNewWb).Names.Add Name:=x.Name, _
RefersTo:=x.Value
Next x



Thanks for your help in this - however, it is throwing an error.

Elsewhere in my code, I am getting the 'type mismatch' error on the
following line:
Windows(LOldWb).Activate

Does this need to be simply LOldWb.Activate?

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
ll ll is offline
external usenet poster
 
Posts: 67
Default Copying Range Names to another open workbook

On Apr 27, 3:40 pm, ll wrote:
On Apr 27, 12:10 pm, Vergel Adriano



wrote:
II,


give this a try:


'Define old and new workbooks
Dim LOldWb As Workbook
Dim LNewWb As Workbook
Dim x As Name


Set LOldWb = Workbooks.Open(Filename:=UserForm1.TextBox1.Value)
Set LNewWb = Workbooks.Add


'Loop to copy range names from old to new workbooks
For Each x In LOldWb.Names
LNewWb.Names.Add Name:=x.Name, _
RefersTo:=x.RefersTo
Next x


--
Hope that helps.


Vergel Adriano


"ll" wrote:
Hi,
I am trying to copy my range names to another open workbook. I've
been looking at the script below but can't figure out how to get it to
copy the range names from the first (LOldWb) workbook to the second
(LNewWb) workbook. Thanks, Louis
-------------------------


'Define old and new workbooks
Workbooks.Open Filename:=UserForm1.TextBox1.Value
LOldWb = ActiveWorkbook.Name


Workbooks.Add
LNewWb = ActiveWorkbook.Name


'Loop to copy range names from old to new workbooks


For Each x In LOldWb.Names


Workbooks(LNewWb).Names.Add Name:=x.Name, _
RefersTo:=x.Value
Next x


Thanks for your help in this - however, it is throwing an error.

Elsewhere in my code, I am getting the 'type mismatch' error on the
following line:
Windows(LOldWb).Activate

Does this need to be simply LOldWb.Activate?

Thanks



I just have gotten this to work. I did simply replace all instances
of Windows(LOldWb) to LOldWb

Thanks again,
Louis

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Copying Range Names to another open workbook

Yes, LOldWb.Activate would work.


--
Hope that helps.

Vergel Adriano


"ll" wrote:

On Apr 27, 12:10 pm, Vergel Adriano
wrote:
II,

give this a try:

'Define old and new workbooks
Dim LOldWb As Workbook
Dim LNewWb As Workbook
Dim x As Name

Set LOldWb = Workbooks.Open(Filename:=UserForm1.TextBox1.Value)
Set LNewWb = Workbooks.Add

'Loop to copy range names from old to new workbooks
For Each x In LOldWb.Names
LNewWb.Names.Add Name:=x.Name, _
RefersTo:=x.RefersTo
Next x

--
Hope that helps.

Vergel Adriano

"ll" wrote:
Hi,
I am trying to copy my range names to another open workbook. I've
been looking at the script below but can't figure out how to get it to
copy the range names from the first (LOldWb) workbook to the second
(LNewWb) workbook. Thanks, Louis
-------------------------


'Define old and new workbooks
Workbooks.Open Filename:=UserForm1.TextBox1.Value
LOldWb = ActiveWorkbook.Name


Workbooks.Add
LNewWb = ActiveWorkbook.Name


'Loop to copy range names from old to new workbooks


For Each x In LOldWb.Names


Workbooks(LNewWb).Names.Add Name:=x.Name, _
RefersTo:=x.Value
Next x



Thanks for your help in this - however, it is throwing an error.

Elsewhere in my code, I am getting the 'type mismatch' error on the
following line:
Windows(LOldWb).Activate

Does this need to be simply LOldWb.Activate?

Thanks


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
Defined Names in Formulas when copying Worksheets in a Workbook Todd_Loves_Spreadsheets Excel Discussion (Misc queries) 1 October 22nd 09 05:05 AM
COPYING FORMULA CONTAINING NAMES/RELATIVE RANGE NAMES Bricol Excel Discussion (Misc queries) 0 July 8th 08 03:54 PM
Copying A Worksheet From Each Open Workbook to an new Workbook carl Excel Worksheet Functions 1 January 3rd 06 05:37 PM
Copying Range Names and values from one tab to another Rob Slagle[_3_] Excel Programming 1 August 9th 05 07:12 PM
Copying Worksheet to Another Open Workbook [email protected] Excel Programming 2 September 15th 04 01:32 AM


All times are GMT +1. The time now is 09:53 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"