Share via

Cmd Btn to get sum

Anonymous
2012-02-13T21:05:36+00:00

I want to create a code for the command button in a UserForm I created so when I click the command button the sum of A3 + 1 will show up in A2.  What I have created below doesn’t work so well.  I don’t want to have any formula in A2, just the number value which is equal to A3 + 1.  Can you help? 

Private Sub CommandButton1_Click()

With Sheets("Sheet1")

.Range("A2").Value = A3 + 1

Unload Me

End With

End Sub

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

HansV 462.6K Reputation points
2012-02-13T22:24:12+00:00

Try this version:

Private Sub CommandButton1_Click()

    With Sheets("Sheet1")

        .Range("A2").Value = .Range("A3").Value + 1

    End With

    Unload Me

End Sub

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2012-02-13T23:00:13+00:00

    This is what I was looking for.  Thank you, it is perfect.

    Was this answer helpful?

    0 comments No comments