To copy the cell content you would need VBA. My suggestion is to use event handler for Change event in Sheet2:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
If Not Intersect(Target, Range("A2:B2")) Is Nothing Then
If Len(Range("A2")) * Len(Range("B2")) > 0 Then 'both col A and col B has something inside
If IsNumeric(Range("A2")) And IsNumeric(Range("B2")) Then
Cells(Rows.Count, 5).End(xlUp).Offset(1, 0).Value = Range("A2") * Range("B2")
Else
MsgBox "Both A2 and B2 has to be numbers", vbCritical
End If
End If
End If
End Sub
But to have it working properlu in case you enter a whole new pair of values, you would need to clear the A2:B2 content before.
Otherwise you enter new A2 and oldB2*newA2 will be calculated (this result is not needed) and then when you enter also new B2 proper result newB2*newA2 is stored in first available cell in column E.
But probably it would be better to write these pairs to be multiplied in consequtive rows. Then the code would be:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
If Not Intersect(Target, Columns("A:B")) Is Nothing Then
For Each rng In Intersect(Target, Columns("A:B"))
Cells(rng.Row, 3).ClearContents
Cells(rng.Row, 5).ClearContents
If Len(Cells(rng.Row, 1)) * Len(Cells(rng.Row, 2)) > 0 Then 'both col A and col B has something inside
If IsNumeric(Cells(rng.Row, 1)) And IsNumeric(Cells(rng.Row, 2)) Then
Cells(rng.Row, 3).Formula = "=" & Cells(rng.Row, 1).Address(False, False) & "*" & Cells(rng.Row, 2).Address(False, False)
Cells(rng.Row, 5).Value = Cells(rng.Row, 1) * Cells(rng.Row, 2)
Else
MsgBox "Both Columns A and B has to be numbers", vbCritical
End If
End If
Next rng
End If
End Sub
See attached file (macros execution have to be enabled).
Bookmarks