ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro needs to reference cell values in different worksheets (https://www.excelbanter.com/excel-programming/334149-macro-needs-reference-cell-values-different-worksheets.html)

Capt Jim Cook

macro needs to reference cell values in different worksheets
 
How to I program a macro to add two numbers from a different worksheet (in
the same workbook) and store the result in the current worksheet? I already
tried,

Cells(5, y).Value = Sheets("Summary").Cells(4, 2).Value +
Sheets("Summary").Cells(5, 2).Value

This is preceeded by a loop (also not working because of the worksheet
reference) that looks across row 4 for a matching date so that it can put the
daily data into the historical worksheet. This loop is controlled by:

Do Until Cells(4, y).Value = Sheets("Summary").Cells(2, 3).Value

I think the problem is in trying to reference the other sheet. If it was
just a formula, I would use Summary!Cells(2,3) but that doesn't work in a
macro either.

I'm using Excel 2003. Thanks for your assistance.
Jim

Nuraq

macro needs to reference cell values in different worksheets
 
Use the Worksheets object rather than the Sheets object:

Cells(5,y) = Worksheets("Summary").Cells(4, 2) +
Worksheets("Summary").Cells(5, 2)



"Capt Jim Cook" wrote in message
...
How to I program a macro to add two numbers from a different worksheet (in
the same workbook) and store the result in the current worksheet? I
already
tried,

Cells(5, y).Value = Sheets("Summary").Cells(4, 2).Value +
Sheets("Summary").Cells(5, 2).Value

This is preceeded by a loop (also not working because of the worksheet
reference) that looks across row 4 for a matching date so that it can put
the
daily data into the historical worksheet. This loop is controlled by:

Do Until Cells(4, y).Value = Sheets("Summary").Cells(2, 3).Value

I think the problem is in trying to reference the other sheet. If it was
just a formula, I would use Summary!Cells(2,3) but that doesn't work in a
macro either.

I'm using Excel 2003. Thanks for your assistance.
Jim





All times are GMT +1. The time now is 08:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com