Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default choos one of two comboboxes

Hi,

I have a userform with two comboboxes.
the first one lists the customer name
the second one lists the customer advisor

Depending on which combobox the user selects, i want to use the value the
user selects to pick the customer form the data sheet.
I managed to do it for one combobox using a "retrieve" button called
"ophalen" like this;

Private Sub but_ophalen_Click()
Dim klantkeuze As String
Dim naamtotaal As String
klantkeuze = zoekwg.Value
Set klantmatrix = Worksheets("datadga").Range("B2:b500").Find(klantk euze)
txt_naamwg = Worksheets("datadga").Cells(klantmatrix.Row,
klantmatrix.Column)
etc..
end sub

where
zoekwg = a combobox

My question,
How can i get my form to use either combobox 1 or 2 depending on which
combobox the user chooses ?

I can only imagine a second button for combobox 2 but there must be a more
elegant solution i think?
Please help me.
Pierre


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default choos one of two comboboxes

Hi Pierre

Private Sub but_ophalen_Click()
Dim klantkeuze As String
Dim naamtotaal As String
if not isempty(zoekwg.Value) then
'This Combobox was selected

klantkeuze = zoekwg.Value
Set klantmatrix =
Worksheets("datadga").Range("B2:b500").Find(klantk euze)
txt_naamwg = Worksheets("datadga").Cells(klantmatrix.Row,
klantmatrix.Column)
etc..
elseif not isempty(combobox2.value) ' Fit to suit combobox name
'Combobox2 was selected
' Your code for Combobox2
end if
end sub

Regards, Per

"Pierre" skrev i en meddelelse
...
Hi,

I have a userform with two comboboxes.
the first one lists the customer name
the second one lists the customer advisor

Depending on which combobox the user selects, i want to use the value the
user selects to pick the customer form the data sheet.
I managed to do it for one combobox using a "retrieve" button called
"ophalen" like this;

Private Sub but_ophalen_Click()
Dim klantkeuze As String
Dim naamtotaal As String
klantkeuze = zoekwg.Value
Set klantmatrix = Worksheets("datadga").Range("B2:b500").Find(klantk euze)
txt_naamwg = Worksheets("datadga").Cells(klantmatrix.Row,
klantmatrix.Column)
etc..
end sub

where
zoekwg = a combobox

My question,
How can i get my form to use either combobox 1 or 2 depending on which
combobox the user chooses ?

I can only imagine a second button for combobox 2 but there must be a more
elegant solution i think?
Please help me.
Pierre




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default choos one of two comboboxes

Hi Per,

THANK YOU !

I first got an error message but i quickly saw that you forgot a Then
statement.
Now it works fine !

Thanks again for your help Per.
Pierre

"Per Jessen" schreef in bericht
...
Hi Pierre

Private Sub but_ophalen_Click()
Dim klantkeuze As String
Dim naamtotaal As String
if not isempty(zoekwg.Value) then
'This Combobox was selected

klantkeuze = zoekwg.Value
Set klantmatrix =
Worksheets("datadga").Range("B2:b500").Find(klantk euze)
txt_naamwg = Worksheets("datadga").Cells(klantmatrix.Row,
klantmatrix.Column)
etc..
elseif not isempty(combobox2.value) ' Fit to suit combobox name
'Combobox2 was selected
' Your code for Combobox2
end if
end sub

Regards, Per

"Pierre" skrev i en meddelelse
...
Hi,

I have a userform with two comboboxes.
the first one lists the customer name
the second one lists the customer advisor

Depending on which combobox the user selects, i want to use the value the
user selects to pick the customer form the data sheet.
I managed to do it for one combobox using a "retrieve" button called
"ophalen" like this;

Private Sub but_ophalen_Click()
Dim klantkeuze As String
Dim naamtotaal As String
klantkeuze = zoekwg.Value
Set klantmatrix = Worksheets("datadga").Range("B2:b500").Find(klantk euze)
txt_naamwg = Worksheets("datadga").Cells(klantmatrix.Row,
klantmatrix.Column)
etc..
end sub

where
zoekwg = a combobox

My question,
How can i get my form to use either combobox 1 or 2 depending on which
combobox the user chooses ?

I can only imagine a second button for combobox 2 but there must be a
more elegant solution i think?
Please help me.
Pierre






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default choos one of two comboboxes

Hi Pierre

Thanks again for your reply.

Good you could find the missing Then, i didn't test the code :-(

//Per
"Pierre" skrev i en meddelelse
...
Hi Per,

THANK YOU !

I first got an error message but i quickly saw that you forgot a Then
statement.
Now it works fine !

Thanks again for your help Per.
Pierre

"Per Jessen" schreef in bericht
...
Hi Pierre

Private Sub but_ophalen_Click()
Dim klantkeuze As String
Dim naamtotaal As String
if not isempty(zoekwg.Value) then
'This Combobox was selected

klantkeuze = zoekwg.Value
Set klantmatrix =
Worksheets("datadga").Range("B2:b500").Find(klantk euze)
txt_naamwg = Worksheets("datadga").Cells(klantmatrix.Row,
klantmatrix.Column)
etc..
elseif not isempty(combobox2.value) ' Fit to suit combobox name
'Combobox2 was selected
' Your code for Combobox2
end if
end sub

Regards, Per

"Pierre" skrev i en meddelelse
...
Hi,

I have a userform with two comboboxes.
the first one lists the customer name
the second one lists the customer advisor

Depending on which combobox the user selects, i want to use the value
the user selects to pick the customer form the data sheet.
I managed to do it for one combobox using a "retrieve" button called
"ophalen" like this;

Private Sub but_ophalen_Click()
Dim klantkeuze As String
Dim naamtotaal As String
klantkeuze = zoekwg.Value
Set klantmatrix =
Worksheets("datadga").Range("B2:b500").Find(klantk euze)
txt_naamwg = Worksheets("datadga").Cells(klantmatrix.Row,
klantmatrix.Column)
etc..
end sub

where
zoekwg = a combobox

My question,
How can i get my form to use either combobox 1 or 2 depending on which
combobox the user chooses ?

I can only imagine a second button for combobox 2 but there must be a
more elegant solution i think?
Please help me.
Pierre








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
comboboxes [email protected] uk Excel Discussion (Misc queries) 1 December 6th 09 05:07 PM
COMBOBOXES Zigball Excel Programming 1 December 19th 06 01:10 AM
comboboxes Zaahir Excel Programming 1 October 27th 06 02:43 PM
ComboBoxes Ryan Excel Programming 0 April 14th 04 10:56 PM
Comboboxes David W[_3_] Excel Programming 1 August 29th 03 11:13 PM


All times are GMT +1. The time now is 07:01 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"