sum of 2 variables and keeping them

K_P

New Member
Joined
Apr 1, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi

Like many others,i have a simple problem with excel/VB.

I would like to calculate the sum of each dish ordered in one evening. To this point i have each order added up to an amount and then emptied again with a button.

I had that cell copied to another cell so that it can be added with the new order but I am confused with this beacaus i am not that skilled with excel VB

does anyone have an easy solution?
-----------------------------------------------------

Private Sub CommandButton1_Click()

Range("C2:C20").ClearContents

MsgBox " Order reset"

End Sub

Private Sub CommandButton2_Click()

Range("C3").Copy Destination:=Range("P3")

Range("Q3").Formula = "=SUM(C3,$P$3)"
'Sheets("order").Range("Q3").Value = WorksheetFunction.Sum(Range(Cells(3, 3), Cells(3, 15)))

End Sub
 

Attachments

  • screen.PNG
    screen.PNG
    14.9 KB · Views: 6

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hi K_P. It's not that clear what you want to achieve but I think I get the gist. If you want to add the sum of order sheet C2:C20 to a running total in Q3 then this will work. If I'm not quite right, U will have to provide some more info. HTH. Dave
Code:
With Sheets("order")
.Range("Q3").Value = .Range("Q3").Value + _
            Application.WorksheetFunction.Sum(.Range(.Cells(2, 3), .Cells(20, 3)))
End With
 
Upvote 0

Forum statistics

Threads
1,215,674
Messages
6,126,149
Members
449,294
Latest member
Jitesh_Sharma

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top