Add formula to this sheet to Sum values of range in another worksheet

  • Thread starter Thread starter Richard
  • Start date Start date
R

Richard

Can someone help me with this.

I am an experienced Access Programmer, but a newbie in Excel.

I am trying to add a formula to a cell in code that will sum the
values of an (unnamed) range in another workbook (closed).

If that is not possible, can someone help me with the coding to open
the other workbook and paste the sum of the values of the range in
THAT workbook into a cell in THIS workbook.

Thank you very much.

Richard


Its a good job Einstein never had to fill out one of these Government Grant applications or we never would have found out what e equalled. The West Wing
 
Hi
try something like the following:

Activecell.formula = "=SUM('C:\temp\[book2.xls]sheet1'!A1:A20)"


--
Regards
Frank Kabel
Frankfurt, Germany

Richard said:
Can someone help me with this.

I am an experienced Access Programmer, but a newbie in Excel.

I am trying to add a formula to a cell in code that will sum the
values of an (unnamed) range in another workbook (closed).

If that is not possible, can someone help me with the coding to open
the other workbook and paste the sum of the values of the range in
THAT workbook into a cell in THIS workbook.

Thank you very much.

Richard


Its a good job Einstein never had to fill out one of these Government
Grant applications or we never would have found out what e equalled.
The West Wing
 
If you are putting a formula in a cell it would be

=Sum('C:\Myfolder\[Myfile.xls]Sheet1'!A1:A10)

to put it in the cell using code
ActiveCell.formula = "=Sum('C:\Myfolder\[Myfile.xls]Sheet1'!A1:A10)"

if you then want to remove the formula and leave the computed value

ActiveCell.Formula = ActiveCell.Value

VBA generally doesn't support linking to closed workebooks although there
are workarounds for some specific types of linking - using Excel 4 macros,
use a data management library like ADO and so forth.

--
Regards,
Tom Ogilvy



Richard said:
Can someone help me with this.

I am an experienced Access Programmer, but a newbie in Excel.

I am trying to add a formula to a cell in code that will sum the
values of an (unnamed) range in another workbook (closed).

If that is not possible, can someone help me with the coding to open
the other workbook and paste the sum of the values of the range in
THAT workbook into a cell in THIS workbook.

Thank you very much.

Richard


Its a good job Einstein never had to fill out one of these Government
Grant applications or we never would have found out what e equalled. The
West Wing
 

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

Back
Top