Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default How can I sum up several check boxes conditioned by a combo box?

Hello,

So I have a Form and in there I have several check boxes. Some of them
have the same value, like 1 $. I want when I choose more check boxes
he multiplies the quantity of check boxes with 1 $.

Example:

Check Box 1 is checked, Check Box 4 is checked, Check Box 7 is also
checked. The Check Boxes in between are not checked. All this Check
Boxes (from 1 to 7) have the value of 1 $. So because I choose 1, 4
and 7 I will have the Sum of 3 $. If I choose also Check Box 5 for
example the sum should change into 4 $ and so on. But these Check
Boxes are conditioned by a Size Combo Box with the values: "little",
"middle" and "big"... so if I choose "middle" in the Combo box the
value of the Check Boxes which is the same for all check boxes becomes
now 2 $. So if I have chosen "middle" in the Combo Box and the Check
Box 1 is checked, Check Box 4 is checked and Check Box 7 is also
checked then he has to add 2$ + 2$ + 2$. Same story for "big" but the
Check boxes have now the value of 3$.... (the 1$ example was for the
"little" value of the combo box)

I already thought of a code like this, but which is to long if I would
make it for all Check Boxes and all Combo Box values, and I want a
shorter version if it is possible:

total = 0
If (CheckBox1 = True) Then
If (cboCourse = "Big") Then
total = total + 3
End If
End If
If (CheckBox2 = True) Then
If (cboCourse = "Big") Then
total = total + 3
End If
End If
If (CheckBox3 = True) Then
If (cboCourse = "Big") Then
total = total + 3
End If
End If
If (CheckBox4 = True) Then
If (cboCourse = "Big") Then
total = total + 3
End If
End If
.....
If (CheckBox1 = True) Then
If (cboCourse = "middle") Then
total = total + 2
End If
End If
If (CheckBox2 = True) Then
If (cboCourse = "middle") Then
total = total + 2
End If
End If
.....
If (CheckBox1 = True) Then
If (cboCourse = "little") Then
total = total + 1
End If
End If
If (CheckBox2 = True) Then
If (cboCourse = "little") Then
total = total + 1
End If
End If
.....
ActiveCell.Offset(0, 9).Value = total


Please use also the codes: "total = 0" and "ActiveCell.Offset(0,
9).Value = total"


Thank you very much!

Radu
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default How can I sum up several check boxes conditioned by a combo box?

any ideas?
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default How can I sum up several check boxes conditioned by a combo box?

I'm not sure I understand, but maybe...

Can't you just total up the number of checkboxes that are checked.

The multiply that number by 1, 2 or 3--based on the value of the single
combobox.

Option Explicit
Private Sub CommandButton1_Click()

Dim mySum As Long
Dim myTotal As Long
Dim myMultiplier As Long

mySum = 0
'in VBA true = -1, so we subtract!
mySum = mySum - CBool(Me.CheckBox1.Value = True)
mySum = mySum - CBool(Me.CheckBox2.Value = True)
mySum = mySum - CBool(Me.CheckBox3.Value = True)

Select Case LCase(Me.ComboBox1.Value)
Case Is = LCase("small"): myMultiplier = 1
Case Is = LCase("middle"): myMultiplier = 2
Case Is = LCase("big"): myMultiplier = 3
Case Else
myMultiplier = 0 '???
End Select

myTotal = mySum * myMultiplier

MsgBox myTotal

End Sub

wrote:

Hello,

So I have a Form and in there I have several check boxes. Some of them
have the same value, like 1 $. I want when I choose more check boxes
he multiplies the quantity of check boxes with 1 $.

Example:

Check Box 1 is checked, Check Box 4 is checked, Check Box 7 is also
checked. The Check Boxes in between are not checked. All this Check
Boxes (from 1 to 7) have the value of 1 $. So because I choose 1, 4
and 7 I will have the Sum of 3 $. If I choose also Check Box 5 for
example the sum should change into 4 $ and so on. But these Check
Boxes are conditioned by a Size Combo Box with the values: "little",
"middle" and "big"... so if I choose "middle" in the Combo box the
value of the Check Boxes which is the same for all check boxes becomes
now 2 $. So if I have chosen "middle" in the Combo Box and the Check
Box 1 is checked, Check Box 4 is checked and Check Box 7 is also
checked then he has to add 2$ + 2$ + 2$. Same story for "big" but the
Check boxes have now the value of 3$.... (the 1$ example was for the
"little" value of the combo box)

I already thought of a code like this, but which is to long if I would
make it for all Check Boxes and all Combo Box values, and I want a
shorter version if it is possible:

total = 0
If (CheckBox1 = True) Then
If (cboCourse = "Big") Then
total = total + 3
End If
End If
If (CheckBox2 = True) Then
If (cboCourse = "Big") Then
total = total + 3
End If
End If
If (CheckBox3 = True) Then
If (cboCourse = "Big") Then
total = total + 3
End If
End If
If (CheckBox4 = True) Then
If (cboCourse = "Big") Then
total = total + 3
End If
End If
....
If (CheckBox1 = True) Then
If (cboCourse = "middle") Then
total = total + 2
End If
End If
If (CheckBox2 = True) Then
If (cboCourse = "middle") Then
total = total + 2
End If
End If
....
If (CheckBox1 = True) Then
If (cboCourse = "little") Then
total = total + 1
End If
End If
If (CheckBox2 = True) Then
If (cboCourse = "little") Then
total = total + 1
End If
End If
....
ActiveCell.Offset(0, 9).Value = total

Please use also the codes: "total = 0" and "ActiveCell.Offset(0,
9).Value = total"

Thank you very much!

Radu


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default How can I sum up several check boxes conditioned by a combo box?

Thank you very much! It was exactly what I needed!
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default How can I sum up several check boxes conditioned by a combo box?

Thank you very much! It was exactly what I needed!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I increase the size of check in check boxes Adams, Les Excel Discussion (Misc queries) 0 September 19th 06 02:35 PM
Enable check box in protected sheet + group check boxes Dexxterr Excel Discussion (Misc queries) 4 August 2nd 06 12:00 PM
Selecting subsets using combo boxes or list boxes CLamar Excel Discussion (Misc queries) 0 June 1st 06 07:43 PM
Questions on combo boxes and list boxes. Marc New Users to Excel 1 March 14th 06 09:40 AM
How do i create a value for check boxes or option boxes Tim wr Excel Discussion (Misc queries) 1 February 9th 06 10:29 PM


All times are GMT +1. The time now is 11:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"