PDA

View Full Version : Solved: Associate values checkbox and sum



jmaocubo
11-03-2011, 10:25 AM
I've a userform with 5 checkboxes and 1 botton

i need that every checkbox has a number associated so when i click in botton1

those values sum

e.g.: associate value 5 to checkbox1, 3 to checkbox2 and 10 to checkbox3, 4 to checkbox4, 13 to checkbox5

if i enable checkbox1 and checkbox2 in sheet("auxiliar").range("E5")=(5+10) after click botton1.

thanks in advance

GTO
11-03-2011, 10:40 AM
Maybe something like:
Option Explicit

Private Sub CommandButton1_Click()
Dim lVal As Long

With Me
lVal = Abs(.CheckBox1.Value * 5) _
+ Abs(.CheckBox2.Value * 3) _
+ Abs(.CheckBox3.Value * 10) _
+ Abs(.CheckBox4.Value * 4) _
+ Abs(.CheckBox5.Value * 13)
End With

ThisWorkbook.Worksheets("auxiliar").Cells(5, 5).Value = lVal
End Sub

jmaocubo
11-03-2011, 10:48 AM
Thanks GTO it works fine....

GTO
11-03-2011, 10:53 AM
You are most welcome :-)