Sum Values from User Form

Roller

Board Regular
Joined
Jan 31, 2005
Messages
113
Hello all,

I would appreciate any help in trying to calculate the sum of several values that are captured in a user form. I have a user form where clerks will input inbound mail volumes into a user form. I am looking for a line of code to put into this macro so that the values from cells(iRow,4) through cells(iRow,13) are summed together. The macro runs but the column N (14th column) on my destination sheet is blank.

This line is code is not functioning properly....
ws.Cells(iRow, 14).Value = Range(Cells(iRow, 4), Cells(iRow, 13)).Calculate

Thank you, in advance, for any help from this forum!!!

Below is my entire macro for the user form....
Private Sub cmdAdd_Click()

Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Retail Inbound Volume")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'input the data to the database
ws.Cells(iRow, 1).Value = Me.WorkDate.Value
ws.Cells(iRow, 2).Value = Me.LockBox.Value
ws.Cells(iRow, 3).Value = Me.OpSite.Value
ws.Cells(iRow, 4).Value = Me.s630.Value
ws.Cells(iRow, 5).Value = Me.s900.Value
ws.Cells(iRow, 6).Value = Me.s1100.Value
ws.Cells(iRow, 7).Value = Me.s100.Value
ws.Cells(iRow, 8).Value = Me.s600.Value
ws.Cells(iRow, 9).Value = Me.m630.Value * 800
ws.Cells(iRow, 10).Value = Me.m900.Value * 800
ws.Cells(iRow, 11).Value = Me.m1100.Value * 800
ws.Cells(iRow, 12).Value = Me.m100.Value * 800
ws.Cells(iRow, 13).Value = Me.m600.Value * 800
ws.Cells(iRow, 14).Value = Sum(Range(Cells(iRow, 4), Cells(iRow, 13)).Calculate)
ws.Cells(iRow, 15).Value = Me.Clerk.Value
ws.Cells(iRow, 16).Value = Month(Me.WorkDate.Value)
ws.Cells(iRow, 17).Value = Year(Me.WorkDate.Value)

'clear the data and resets form for repeated input.
Me.LockBox.Value = ""
Me.s630.Value = 0
Me.s900.Value = 0
Me.s1100.Value = 0
Me.s100.Value = 0
Me.s600.Value = 0
Me.m630.Value = 0
Me.m900.Value = 0
Me.m1100.Value = 0
Me.m100.Value = 0
Me.m600.Value = 0
Me.LockBox.SetFocus

End Sub
 
Sum does not exist like this in VBA

Solution 1
dim i as integer

for i = 4 to 13
ws.Cells(iRow, 14).Value =
ws.Cells(iRow, 14).Value + ws.Cells(iRow, i).Value
next i

Solution 2 (Keeps the formula)
Cells(2, 14).FormulaR1C1 = "=SUM(RC[-10]:RC[-1])"

Solution 3 (Saves just the value)
With Cells(2, 14)
.FormulaR1C1 = "=SUM(RC[-10]:RC[-1])"
.value = .value
end with
 
Upvote 0

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