VB How-ToAsk your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VB How-To section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
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