PDA

View Full Version : Updating Defined Named Lists (Difficult)



Mooseman60
10-24-2010, 07:32 AM
:banghead: This going to hard to explain but here goes

I have created a workbook (which i will call Template for the purpose of trying to explain) with approx 10 worksheets to record various elements of a project plus lists to populate combo boxes on userforms. These worksheets will be hidden

The first userform has a combo box and text box to look up Job Name and Job Number. Once selected there is a command button to open existing saved Job No.xls file which is saved in a folder named Project Costs in My Documents
I have also created a Userform Menu with command buttons to open userforms to enter data to the relevant worksheets. This userforms have combo boxes to select certain data from the Defined Name Lists in the hidden worksheets. If the required data is not in the combo box list there is a command button to open a sub userform to enter the data and update the relevant Defined Name Lists. This all works fine until I save the workbook as a Job No 001.xls file and open the Template workbook again to record data for another Job No 002.xls, my problem is that the data that was saved to the previous Job No 001.xls file doesn't show up in the Template Workbook defined name Lists

What i need to happen is once any data is entered in sub userforms to up date the Defined Names Lists the data needs to save to the Template Workbook Defined Name Lists as well

I hope this makes sense to someone quite happy to send further information if required

Jan Karel Pieterse
10-24-2010, 07:39 AM
Sounds like you'll benefit from seperating logic from data.

You could have three files:
- an xla which contains all VBA
- A (hidden) xls with the named lists (opened by the xla)
- One or more project files

What the xla needs to do of course is keep track of whether a file is "owned" by the xla and act accordingly regarding its user interface.

Huge benefit:
- updating VBA code is easy (just one xla)
- Updating lists is equally easy (just one file)

Mooseman60
10-25-2010, 01:45 AM
Jan

As I said I am a novice at VBA only been playing with it for a week, how would i go about doing what you suggest

Jan Karel Pieterse
10-25-2010, 10:17 AM
Here is a good start:
www.jkp-ads.com/articles/distributemacro00.asp (http://www.jkp-ads.com/articles/distributemacro00.asp)