Combobox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a couple of macros which:

a) sort a list by client
b) sort a list by value

I need two options within the combo box
and when I choose option "SORT-CLIENT" the first macro is run

Thks
 
In two cells, say AA1 and AA2, put the values SORT-CLIENT and SORT-LIST,
select a combobox form the Forms toolbar, and right-click the combox to
select Format Control from the menu, and on the Control tab set the Input
Range texbox to AA1:AA2, and the Cell link textbox to AA3. OK out.

Add this macro to a general code module

Sub SortData()
If Worksheets("Sheet1").Range("AA3").Value ="SORT-CLIENT" Then
SortbyClientMacro
Else
SortByValueMacro
End If
End Sub

Now go back to the worksheet, right-click the combobox again, select Assign
Macro, and assign the above macro to the combobox.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Thanks Bob - thats very helpful



Bob Phillips said:
In two cells, say AA1 and AA2, put the values SORT-CLIENT and SORT-LIST,
select a combobox form the Forms toolbar, and right-click the combox to
select Format Control from the menu, and on the Control tab set the Input
Range texbox to AA1:AA2, and the Cell link textbox to AA3. OK out.

Add this macro to a general code module

Sub SortData()
If Worksheets("Sheet1").Range("AA3").Value ="SORT-CLIENT" Then
SortbyClientMacro
Else
SortByValueMacro
End If
End Sub

Now go back to the worksheet, right-click the combobox again, select Assign
Macro, and assign the above macro to the combobox.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Ive tried the below - howver doesnt seem to call CL, always calls "Value"

Thanks

Private Sub ComboBox1_Change()

If Worksheets("Sheet1").Range("AA3").Value = "C" Then
Call CL
Else
Call Value
End If
End Sub
 
Try:

Private Sub ComboBox1_Click()

If Combobox1.value = "C" Then
Call CL
Else
Call Value
End If
End Sub
 
Thanks Tom - works fine

Tom Ogilvy said:
Try:

Private Sub ComboBox1_Click()

If Combobox1.value = "C" Then
Call CL
Else
Call Value
End If
End Sub
 
steps:
1. create the combobox
2. populate the combobox
3. assign a routine to a combobox event
4. code the routine
Which step are you on?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top