Sum Total Checkboxes on a Multipage Form
Hi All,
I have a function which is intended to collate the sum total of checkboxes checked on a mulitpage form. Each checkbox has a numerical value and these values are referenced on an underlying excel spreadsheet (worksheet 3). I have been unsuccessful in getting the checkboxes to sum total what has been selected. However, I have gotten this same function to work if I embed the checkboxes onto the excel spreadsheet itself, but i need this to work on in forms. Any ideas on where the link is broken so to speak?
Private Sub CommandButton1_Click()
'
' Sum checkboxes
'
Dim rngCheckTable As Range
Dim Chk As Object
Dim dblTotal As Double
Dim dblValue As Double
On Error Resume Next
Set rngCheckTable = Excel.Worksheets(3).Range("A1:B11")
For Each Chk In frmViewResults.MultiPage1.Pages(0)
If TypeName(Chk.Object) = "CheckBox" Then
dblValue = 0
If Chk.Object.Value = True Then
dblValue = Application.WorksheetFunction.VLookup(Chk.Name, rngCheckTable, 2, 0)
End If
dblTotal = dblTotal + dblValue
End If
Next
txtbxQuantityScore.Text = dblTotal
MsgBox "Total is " & dblTotal
End Sub
|