View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Mike Fogleman Mike Fogleman is offline
external usenet poster
 
Posts: 1,092
Default How to summarize two sheets in the third sheet

Similar to Ron's code here is one that will fire automatically each time
you change cells in sheet1. You would put the code in the code module for
sheet1, not a general code module:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim c As Range
With Selection
If .Cells.Count = 1 Then
.Value = Worksheets("Sheet2").Range(Target.Address).Value + _
Worksheets("Sheet3").Range(Target.Address).Value
Else
For Each c In Target
c.Value = Worksheets("Sheet2").Range(c.Address).Value + _
Worksheets("Sheet3").Range(c.Address).Value
Next c
End If
End With
End Sub

P.S. if you need to constrain this code to work only in a certain range on
the worksheet, post back.

Mike F
"L.K." wrote in message
...
Dear All,

I have three sheets (sheet1, sheet2, sheet3)

I want to write macro which will do following:
I will select some cells in the "sheet1" and in each cell of the selection
write sum of the same coordinate cells from sheet2 and sheet3.

Thank you for your help.
Lado