Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default ComboBox Exit

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default ComboBox Exit

Assuming the Comboboxes are on a userform.

For methods that belong to the combobox, you can. However, the exit event
belongs to the control object and for that you can't. You can write single
routine which is called from the exit event of each combobox, so that would
reduce you burden somewhat.

Private Sub C1_Exit()
ExitCode C1
End Sub

Sub ExitCode(cbx as MSForms.Combobox)
dim cbx1 as MSForms.Combobox
dim ctl as Control
for each ctl in Userform1.Controls
if typeof ctl is MSForms.Combobox then
set cbx1 = ctl
if cbx1.Name < cbx.Name then
cbx1.Enabled = False
end if
end if
Next
End Sub

--
Regards,
Tom Ogilvy

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default ComboBox Exit

Hi Bob,

Thanks for this interesting codes. I will try it. Thanks
for your help.

Regards
Sadik


-----Original Message-----
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



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default ComboBox Exit

Hi Tom,

Didn't think of this method. This makes sense. Thanks for
your help.

Regards
Sadik

-----Original Message-----
Assuming the Comboboxes are on a userform.

For methods that belong to the combobox, you can.

However, the exit event
belongs to the control object and for that you can't.

You can write single
routine which is called from the exit event of each

combobox, so that would
reduce you burden somewhat.

Private Sub C1_Exit()
ExitCode C1
End Sub

Sub ExitCode(cbx as MSForms.Combobox)
dim cbx1 as MSForms.Combobox
dim ctl as Control
for each ctl in Userform1.Controls
if typeof ctl is MSForms.Combobox then
set cbx1 = ctl
if cbx1.Name < cbx.Name then
cbx1.Enabled = False
end if
end if
Next
End Sub

--
Regards,
Tom Ogilvy

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



.

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
fill combobox depending on selection from another combobox Adam Francis Excel Discussion (Misc queries) 2 July 24th 08 07:39 PM
Exit Sub Jeff Excel Discussion (Misc queries) 2 March 1st 08 06:21 PM
Run when exit PH NEWS Excel Worksheet Functions 1 July 18th 06 03:53 PM
combobox exit event Dave D[_3_] Excel Programming 0 April 28th 04 10:22 PM
If a called sub exit, how to the caller exit right away? luvgreen[_4_] Excel Programming 4 February 24th 04 05:06 PM


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

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"