![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Location: Manchester, UK
Posts: 95
|
Is it possible to define names in multiple workbooks? I am currently defining a name in one workbook but a need has arisen for this name to also be defined in a second workbook (which is open but hidden in the background). I'm using the following statement to define the name - how do I extend it to define it in a second sheet?
If [b7] = "Turnip" Then ActiveWorkbook.Names.Add Name:="ValidData", RefersToR1C1:= _ "='[Carrots.xls]Parsnips'!R25C1:R50C1" |
|
|
|
|
|
#2 | |
|
Board Regular
Join Date: Feb 2002
Posts: 74
|
Quote:
I've assumed here that you have defined OtherWorkbook elsewhere in the procedure to refer to the hidden workbook. If [b7] = "Turnip" Then ActiveWorkbook.Names.Add Name:="ValidData", RefersToR1C1:= _ "='[Carrots.xls]Parsnips'!R25C1:R50C1" OtherWorkbook.Names.Add Name:="ValidData", RefersToR1C1:= _ "='[Carrots.xls]Parsnips'!R25C1:R50C1" End if
__________________
"Interfere? Of course we should interfere! Always do what you're best at, that's what I say!" -- The Doctor, Nightmare of Eden |
|
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Mar 2002
Location: Manchester, UK
Posts: 95
|
What do I need to define OtherWorkbook as? String, Workbook, Boolean ......?
I'm still learning the ins and out so you'll have to excuse my ignorance. Cheers. |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Mar 2002
Location: Manchester, UK
Posts: 95
|
Can nobody help me out on this one?
|
|
|
|
|
|
#5 | |
|
Board Regular
Join Date: Feb 2002
Posts: 74
|
Quote:
You can use Dim Otherworkbook as Workbook and then Set it in context, e.g., when you open the hidden workbook (and it's active), Set OtherWorkbook = ActiveWorkbook (There are other, clever ways to do this, but this is easy and generally foolproof.) HTH
__________________
"Interfere? Of course we should interfere! Always do what you're best at, that's what I say!" -- The Doctor, Nightmare of Eden |
|
|
|
|
|
|
#6 | |
|
Board Regular
Join Date: Mar 2002
Location: Manchester, UK
Posts: 95
|
Quote:
If I want to add the name valid data to a workbook called Potato.xls, along with the above procedure, how do I define the operation. Please help. I'm very stuck!! |
|
|
|
|
|
|
#7 | ||
|
Board Regular
Join Date: Feb 2002
Posts: 74
|
Quote:
right after the VBA opened that file).
__________________
"Interfere? Of course we should interfere! Always do what you're best at, that's what I say!" -- The Doctor, Nightmare of Eden |
||
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|