Reference of Range in another file with VB

  • Thread starter Thread starter Steven P
  • Start date Start date
S

Steven P

Hi all:

A new problem comes to me, maybe some of you have already experience
on it.
Because of the file size (18 MB), I split this excel file (containing
VB code) in two files A and B.

Now is the problem:
1. The Config sheet of file A contains some data which will be used by
two files. In this sheet are several Ranges defined. These range are
used by other sheets which are now in both files and in VB code.

Question:
1. How can I make a reference to a range in file Afrom VB code in file
B?
I have tried to use like

for each a in [A]Config!ref_range

or:

for each a in ["A"]Config!ref_range

Neither woks.

2. I opened the linked excel file A with VB program. Is it unnessary
because there are already links between sheets? Will two instance of
the excel file A be opened? If I don't do it in VB, the VB code
doesn't run. Is there a better way to do it?
 
dim c as range

for each c in workbooks("A.xls").range("ref_range").cells
'do stuff
next c


Tim
 
Thank you, it works with
workbooks(...).Worksheets(...).range("...").cells

You have saved my day.

dim c as range

for each c in workbooks("A.xls").range("ref_range").cells
'do stuff
next c

Tim




A new problem comes to me, maybe some of you have already experience
on it.
Because of the file size (18 MB), I split this excel file (containing
VB code) in two files A and B.
Now is the problem:
1. The Config sheet of file A contains some data which will be used by
two files. In this sheet are several Ranges defined. These range are
used by other sheets which are now in both files and in VB code.
Question:
1. How can I make a reference to a range in file Afrom VB code in file
B?
I have tried to use like
for each a in [A]Config!ref_range

for each a in ["A"]Config!ref_range
Neither woks.
2. I opened the linked excel file A with VB program. Is it unnessary
because there are already links between sheets? Will two instance of
the excel file A be opened? If I don't do it in VB, the VB code
doesn't run. Is there a better way to do it?- Zitierten Text ausblenden -

- Zitierten Text anzeigen -
 
Back
Top