Thread: ComboBox Exit
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default ComboBox Exit

Here's a technique I got from John Walkenbach, and have adapted for your
combos.

First, create a class with the following code

Public WithEvents ComboGroup As ComboBox

Private Sub ComboGroup_Click()
MsgBox "Hello from " & ComboGroup.Name
End Sub


The click event here is your universal procesure, put your specific code in
their.

Then in a normal module, add this procedure to setup the combobox array.

Dim Combos() As New Class1

Sub ShowDialog()
Dim cCombos As Long
Dim ctl As Control

' Create the Combobox objects
cCombos = 0
For Each ctl In UserForm1.Controls
If TypeName(ctl) = "ComboBox" Then
cCombos = cCombos + 1
ReDim Preserve Combos(1 To cCombos)
Set Combos(cCombos).ComboGroup = ctl
End If
Next ctl
UserForm1.Show
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

wrote in message
...
Hio All,

I have a few ComboBoxes on a userform e.g. C1, C2 C3 etc.
I want to put the same procedure for all of them which
would be trigered on exitiing the relevant ComboBox. The
codes would include the following line, say exiting C1:

C2.enabled = false
C3.enabled = false

My two questions a

1. Can I write a single (I ahve quite a few Combos)
procedure that will perform on exiting any combo on the
userform and how?
2. Can the above code be included?

Thanks for your help in advance.

Regards