Declare Variable

  • Thread starter Thread starter zapatista66
  • Start date Start date
Z

zapatista66

Hola Todos ! I need some help. I want to declare some variables for al
my modules.

Ex:

Public wbBook1 as workbook, wbBook2, etc

Set wbBook1 = workbooks("roger.xls")

I don't want to write these lines in each modules. Want I start m
principal workbook I open all workbooks needed in my programmation
After, I look in some workbook and I write in the other.

thanks for helping m
 
Zapatista66,
You're almost there. In your Workbook_Open procedure call
another public procedure that I call SetRefs. SetRefs has
all of your Set statements and you make the all of the
objects global in scope. Then your other procs will see
the objects.
Also, while testing a procedure, throw SetRefs into the
top of the procedure so when you get a runtime error you
don't have to go look for Workbook_Open or SetRefs again.
Just fix your code and F5.
Geof.
 
Back
Top