PDA

View Full Version : call code



jono19872006
08-16-2012, 02:36 AM
At the moment i have code that loops through a folder and formats reports.

At the top of this code there is a few variables that i have defined in the code based on defined ranges in the workbook.

effectively my code is:

1) VARIABLES DEFINED (BASED ON DEFINED RANGES IN OPEN WORKBOOK WHERE MACRO STORED)
2) CODE TO OPEN WORKBOOKS IN DEFINED FOLDER
3) CODE TO FORMAT REPORTS (CALLED IN FROM OTHER SUB)
4) CODE TO EXIT WORKBOOK & LOOP ROUND
5) SOME OTHER FORMATS TO CENTRAL WORKBOOK WHERE MACRO STORED


The formats that i call make reference to the defined variables - however they dont seem to be recognised.
They worked fine before when i have one long list of code (i recently changed so that i called the formats in as a seperate sub).
It seems that when a different workbook is opened then obviously the defined names arent in this one so it doesnt recognise them and kicks it out as an error.
However they are defiend in the main set of code at the top when in the right workbook?

what am i doing wrong?

Bob Phillips
08-16-2012, 03:00 AM
Post the code.

jono19872006
08-16-2012, 03:22 AM
hi thanks, i managed to google it- i just needed to make them public variables