Reference of Range in another file with VB

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?
 
T

Tim Williams

dim c as range

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


Tim
 
S

Steven P

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 -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top