Hi guys,

I'm trying to add the variables "indv" and "ttl" throughout a loop.

instead of summing the numbers i.e. 1+2=3, the macro simply adds them as strings i.e. 1+2=12.

any idea what I'm doing wrong?

here's my code

Private Sub CommandButton1_Click()
Dim i As Integer
Dim ttl, indv, old_afh, new_afh, old_bal, new_bal As Double
Dim myrange, Found As Range

Worksheets("Current Status").Activate
Range("$A$2").Select
i = 1

'''Unprotecting the worksheet'''
ActiveSheet.Unprotect

Do While i <= 13

indv = Me.Controls("Textbox" & i).Value
ttl = ttl + indv

changestat:

If Me.Controls("Combobox" & i).Value = vbNullString Then GoTo changeafh
ActiveCell.Offset(i, 1).Value = Me.Controls("ComboBox" & i).Value


changeafh:

If Me.Controls("Textbox" & i).Value = vbNullString Then GoTo Changei
old_afh = ActiveCell.Offset(i, 5).Value
new_afh = old_afh + indv
ActiveCell.Offset(i, 5).Value = new_afh

'---------------------------------------------------------------------------------------------------

Set Found = Worksheets("Hour Flown").Columns("A").Find(What:=Format(Range("$B$1").Value, "d-mmm-yy"), LookIn:=xlValues, LookAt:=xlWhole)
If Not Found Is Nothing Then
    'MsgBox Found.Address(False, False)
    Found.Offset(, i + 2).Value = indv
End If

Changei:
i = i + 1
Loop
MsgBox ttl
ActiveSheet.Protect

Unload Me
End Sub