#1   Report Post  
Posted to microsoft.public.excel.programming
JT JT is offline
external usenet poster
 
Posts: 234
Default Combo Boxes

I have a user form that has 2 combo boxes. 1 is for debits and the other is
for credits. Each form is multi-select.

I am adding 2 labels; one at the top of each combox. I would like to
display the total of all selected in each combobox. If the user selects
another item, the amount displayed increases. Likewise, it the user
de-selects an item, the amount displayed decreases.

There are 6 fields in each combobox. The amount is the 3rd field in the
debit side and the the 4th field in the credit side.

I'm having a little difficulty getting started. How can I tell when an item
as been selected and when it has been de-selected.

Any help would be greatly appreciated. Thanks for the help.......

--
JT
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Combo Boxes

First, I wouldn't use a combobox for this.

I'd use a listbox. The user can see what they selected--and change their
choices whenever they want.

I built a small userform with a couple of commandbuttons (ok and cancel). A
single listbox and a label. (you can use the same idea with the second listbox
and second label.

Anyway...

This is the code behind the userform:

Option Explicit
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub ListBox1_Change()
Dim iCtr As Long
Dim HowMany As Long
Dim HowMuch As Double

HowMany = 0
HowMuch = 0
With Me.ListBox1
For iCtr = 0 To .ListCount - 1
If .Selected(iCtr) Then
'.list(ictr,2) is the 3rd column in the list
If IsNumeric(.List(iCtr, 2)) Then
HowMany = HowMany + 1
HowMuch = HowMuch + CDbl(.List(iCtr, 2))
End If
End If
Next iCtr
End With

If HowMany = 0 Then
Me.Label1.Caption = ""
Else
Me.Label1.Caption = HowMany & " Selected--Total: " _
& Format(HowMuch, "$#,##0.00")
End If
End Sub
Private Sub UserForm_Initialize()
Dim myRng As Range
With Worksheets("sheet1")
Set myRng = .Range("a2:f" & .Cells(.Rows.Count, "A").End(xlUp).Row)
End With

With Me.ListBox1
.ColumnCount = myRng.Columns.Count
.RowSource = myRng.Address(external:=True)
.ColumnHeads = True
.ColumnWidths = "20;20;20;20;20;20"
.MultiSelect = fmMultiSelectMulti
.ListStyle = fmListStyleOption
End With

Me.Label1.Caption = ""

With Me.CommandButton1
.Caption = "Ok"
.Default = True
End With

With Me.CommandButton2
.Caption = "Cancel"
.Cancel = True
End With

Me.Caption = "Make your selection!"
End Sub


JT wrote:

I have a user form that has 2 combo boxes. 1 is for debits and the other is
for credits. Each form is multi-select.

I am adding 2 labels; one at the top of each combox. I would like to
display the total of all selected in each combobox. If the user selects
another item, the amount displayed increases. Likewise, it the user
de-selects an item, the amount displayed decreases.

There are 6 fields in each combobox. The amount is the 3rd field in the
debit side and the the 4th field in the credit side.

I'm having a little difficulty getting started. How can I tell when an item
as been selected and when it has been de-selected.

Any help would be greatly appreciated. Thanks for the help.......

--
JT


--

Dave Peterson
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
Getting Combo boxes to change options based on other Combo boxes. Ancient Wolf New Users to Excel 1 March 27th 09 06:29 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
Filtered list for Combo Box ListFillRange - Nested Combo Boxes DoctorG Excel Programming 3 February 23rd 06 12:15 PM
Combo Boxes and Tick Boxes turner2000 Excel Programming 0 September 28th 04 10:01 PM


All times are GMT +1. The time now is 10:35 AM.

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

About Us

"It's about Microsoft Excel"