Posting yesterday to warn somebody about why they shouldn't use global variables reminded me of a little problem I have.
I have a macro which reads a workbook full of coded data, uses a translation table in another workbook to replace each code with its value and puts the result into a new workbook.
This macro uses a form to show a list of all open workbooks and asks the user to select the one containing the coded data and then reuses the form to ask the user to select the workbook containing the translation table.
The form is identical in both cases, other than the prompt (e.g. the first time it's called the prompt reads, "Please select the workbook containing the coded data", etc.)
This all works fine, but two little things are bugging me...
1. At the moment the prompt text is set directly by the code calling the form, e.g.
Please Login or Register to view this content.
2. The result from the form (the workbook to be used) is passed back to the calling macro via a global variable.
Both of these issues strike me as being akward and inelegant. What I'm looking for is a way to call the form as if it were a function...
Please Login or Register to view this content.
Is anything like this possible, or is this just another one of the limitations of VBA?
Bookmarks