1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| Sub Calculate() Application.ScreenUpdating = False With ActiveSheet.Buttons(Application.Caller) If .Caption = "Sum" Then Cells(8, 1).Value = "=R[-2]C+R[-1]C" Cells(8, 2).Value = "=R[-2]C+R[-1]C" Cells(8, 3).Value = "=R[-2]C+R[-1]C" Cells(5, 1).Value = .Caption .Caption = "Subtract" ElseIf .Caption = "Subtract" Then Cells(8, 1).Value = "=R[-2]C-R[-1]C" Cells(8, 2).Value = "=R[-2]C-R[-1]C" Cells(8, 3).Value = "=R[-2]C-R[-1]C" Cells(5, 1).Value = .Caption .Caption = "Multiply" ElseIf .Caption = "Multiply" Then Cells(8, 1).Value = "=R[-2]C*R[-1]C" Cells(8, 2).Value = "=R[-2]C*R[-1]C" Cells(8, 3).Value = "=R[-2]C*R[-1]C" Cells(5, 1).Value = .Caption .Caption = "Divide" ElseIf .Caption = "Divide" Then Cells(8, 1).Value = "=R[-2]C/R[-1]C" Cells(8, 2).Value = "=R[-2]C/R[-1]C" Cells(8, 3).Value = "=R[-2]C/R[-1]C" Cells(5, 1).Value = .Caption .Caption = "Sum" End If End With Application.ScreenUpdating = True End Sub
|