ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   add to a cell with a button (https://www.excelbanter.com/excel-programming/388364-add-cell-button.html)

Donny[_3_]

add to a cell with a button
 
i'm trying to create a button that will add values to a cell when the
button is clicked. The cell that is being added to already has a
value, however. the user will input their data in a few different
places, and hit the button. the code should take the input, perform a
few operations, and then add the result to the value of the cell. my
problem is adding to a cell that already has value.

thanks,
donny


Norman Jones

add to a cell with a button
 
Hi Donny,

Add a CommandButton to the shhet and try
something like:

'=============
Private Sub CommandButton1_Click()
Dim srcRng As Range
Dim destRng As Range

Set srcRng = Me.Range("B1, B3, B5") '<<==== CHANGE
Set destRng = Me.Range("A1") '<<==== CHANGE

With destRng
.Value = .Value + Application.Sum(srcRng)
End With
End Sub
'<<=============


---
Regards,
Norman


"Donny" wrote in message
ps.com...
i'm trying to create a button that will add values to a cell when the
button is clicked. The cell that is being added to already has a
value, however. the user will input their data in a few different
places, and hit the button. the code should take the input, perform a
few operations, and then add the result to the value of the cell. my
problem is adding to a cell that already has value.

thanks,
donny





All times are GMT +1. The time now is 10:33 PM.

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