I have a userform that has several text boxes that I want to sum and then place in a cell on the worksheet. It works great until any of the four text boxes equals 1,000 or more. Here is the beginning of my code. I have bolded the line that isn't working properly. I'm thinking it has to do with a limitation of the Val() function that I am unaware of. Any help would be greatly appreciated! Thanks!
Rich (BB code):
Private Sub cmdAdd_click()
Dim lrw As Long
Dim acell As Range
Dim rng As Range
Dim ws As Worksheet
Dim comp As String
On Error Resume Next
lrw = Cells.Find(What:="*", After:=Range("A1"), LookAt:=xlPart, LookIn:=xlFormulas, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Row
comp = Me.cboCompany.Value
Range("dDComp").Value = "'" & Left(comp, 8)
Range("dDCompName").Value = comp
Set ws = Sheets("Line Types")
Set acell = Worksheets("GL Import Data Batches").Range("A" & lrw + 1)
Set rng = ws.Range("Rebate")
If Left(comp, 4) = "2311" Then Range("dLH").Value = "H"
If Left(comp, 4) = "2310" Then Range("dLH").Value = "L"
rng.Copy acell
acell.Offset(0, 17).Value = txtAmount1.Value
acell.Offset(4, 17).Value = txtAmount2.Value
acell.Offset(8, 17).Value = txtAmount3.Value
acell.Offset(12, 17).Value = txtAmount4.Value
acell.Offset(16, 17).Value = txtAmount5.Value
acell.Offset(20, 17).Value = txtAmount6.Value
acell.Offset(24, 17).Value = Val(txtAmount7.Value) + Val(txtAmount8.Value) + Val(txtAmount9.Value) + Val(txtAmount10.Value)
acell.Offset(26, 17).Value = txtAmount7.Value
acell.Offset(30, 17).Value = txtAmount8.Value
acell.Offset(34, 17).Value = txtAmount9.Value
acell.Offset(38, 17).Value = txtAmount10.Value
Last edited by a moderator: