Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Save lookup data in template (.xlt)

Is it possible to store lookup data in a .xlt template file and access the
sheet from with the VBA code stored in the .xlt file itself?

I created a .xlt template with one worksheet and a toolbar with one button.
This template contains data along with some macros that reference that data.
Unfortunately, the macro ends with an error when run from a workbook without
the referenced worksheet. Is it possible to reference the worksheet
contained within the .xlt template?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Save lookup data in template (.xlt)

When you store the code/data in a .xlt, then every workbook that's based on this
template will contain the code/data.

Have you thought of separating your code/data and putting it into an addin.
Then the user could load the addin when they need the macros.

It might make it easier for you if you ever have to update the code or data--who
knows how many workbooks could have created using the .xlt template workbook.

But in either case (.xlt or .xla), you could refer to a worksheet named "Sheet1"
in the workbook that contains the code with something like:

msgbox thisworkbook.worksheets("sheet1").range("b99").val ue

ThisWorkbook is the workbook that owns the code.

Bill James wrote:

Is it possible to store lookup data in a .xlt template file and access the
sheet from with the VBA code stored in the .xlt file itself?

I created a .xlt template with one worksheet and a toolbar with one button.
This template contains data along with some macros that reference that data.
Unfortunately, the macro ends with an error when run from a workbook without
the referenced worksheet. Is it possible to reference the worksheet
contained within the .xlt template?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Save lookup data in template (.xlt)

Thanks Dave for the tip. I ended up referencing the workbook directly
(requiring it to be opened) and referencing the data from VBA using:

Application.WorksheetFunction.VLookup(myIndex,
Workbooks("Royalties.xls").Sheets("Royalties").Use dRange, 4, False)

The data needs to be modifiable by the user, so I thought it would be best
to keep it in a workbook. The user will need to open the workbook to run
code contained within the workbook.

I was trying to avoid writing a full add-in, but the night is still young :)
....

"Dave Peterson" wrote in message
...
When you store the code/data in a .xlt, then every workbook that's based
on this
template will contain the code/data.

Have you thought of separating your code/data and putting it into an
addin.
Then the user could load the addin when they need the macros.

It might make it easier for you if you ever have to update the code or
data--who
knows how many workbooks could have created using the .xlt template
workbook.

But in either case (.xlt or .xla), you could refer to a worksheet named
"Sheet1"
in the workbook that contains the code with something like:

msgbox thisworkbook.worksheets("sheet1").range("b99").val ue

ThisWorkbook is the workbook that owns the code.

Bill James wrote:

Is it possible to store lookup data in a .xlt template file and access
the
sheet from with the VBA code stored in the .xlt file itself?

I created a .xlt template with one worksheet and a toolbar with one
button.
This template contains data along with some macros that reference that
data.
Unfortunately, the macro ends with an error when run from a workbook
without
the referenced worksheet. Is it possible to reference the worksheet
contained within the .xlt template?


--

Dave Peterson



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
Save as Template Mike Excel Discussion (Misc queries) 2 March 20th 10 11:49 AM
Save as Template janey New Users to Excel 2 March 2nd 10 05:13 PM
When you hit Save on a template, how can you save as worksheet? cwgirl1982 Excel Worksheet Functions 1 September 4th 08 11:18 PM
From Template Save As Help Pammi J New Users to Excel 7 January 16th 07 02:49 PM
Save data in template from a form. Please Help! Myriam Excel Programming 2 July 20th 04 03:02 AM


All times are GMT +1. The time now is 06:23 PM.

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"