![]() |
Sort order via excel userform combobox
I have a similar problem with 4 comboboxes on an Excel Userform. Each
comobox has a list from column A, B, C and D. Column A is the original Sort order by on the worksheet. What I'd like to see is when I select Combobox2 (which is set for column B) that the order is ascending, then if I were to switch to Combobox3, set up for column C that Column C is now sorted in ascending order. If I go back to Combobox1, which is Column A, this is again sorted. I've worked through some code, but I get errors as I make a selection from the list. Thanks! |
Sort order via excel userform combobox
It sounds like you have one column for each combobox. Is there a reason why you
just can't sort just column A in ascending order, then sort just column B, then sort just column C, then sort just column D. There won't be any relationship for each of these rows, though. wrote: I have a similar problem with 4 comboboxes on an Excel Userform. Each comobox has a list from column A, B, C and D. Column A is the original Sort order by on the worksheet. What I'd like to see is when I select Combobox2 (which is set for column B) that the order is ascending, then if I were to switch to Combobox3, set up for column C that Column C is now sorted in ascending order. If I go back to Combobox1, which is Column A, this is again sorted. I've worked through some code, but I get errors as I make a selection from the list. Thanks! -- Dave Peterson |
Sort order via excel userform combobox
On Jul 16, 7:03 pm, Dave Peterson wrote:
It sounds like you have one column for each combobox. Is there a reason why you just can't sort just column A in ascending order, then sort just column B, then sort just column C, then sort just column D. There won't be any relationship for each of these rows, though. wrote: I have a similar problem with 4 comboboxes on an Excel Userform. Each comobox has a list from column A, B, C and D. Column A is the original Sort order by on the worksheet. What I'd like to see is when I select Combobox2 (which is set for column B) that the order is ascending, then if I were to switch to Combobox3, set up for column C that Column C is now sorted in ascending order. If I go back to Combobox1, which is Column A, this is again sorted. I've worked through some code, but I get errors as I make a selection from the list. Thanks! -- Dave Peterson Dave...I don't think that would work. I the four comboboxes, based on what the value is, populates various textboxes. Here is some sample code that I have so far: Private Sub ComboBox1_Change() Dim EmpID Dim Rng As Range Dim ws1 As Worksheet Dim NumRows As Long NumRows = Worksheets("n11").Cells(Rows.Count, "A").End(xlUp).Row - 1 EmpID = CLng(ComboBox1.Value) Set ws1 = Worksheets("n11") Set Rng = ws1.Range("c$1:x$1600") ' This column has Employee ID numbers If ComboBox1.Value < "" Then TextBox1.Value = Application.VLookup(EmpID, Rng, 2, 0) TextBox2.Value = Application.VLookup(EmpID, Rng, 3, 0) TextBox3.Value = Application.VLookup(EmpID, Rng, 4, 0)....onto Textbox20.... Combobox2 would have similar settings only Rng would be set to Column D - X. That is why I was thinking that if the sort option can be initiated as each combobox is selected it would make the list alot more user friendly. This is a great user group and I've gotten assistance from you in the past as well as others so if you have any other suggestions, that would be great. I tried recording a macro that sorted column A (for example) and copied that bit of code in the front of the above code Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom but I got a debug error (Run time error 1004 - Sort Method of Range Class Failed). When I cleared that and reselected the combobox the list was now in order. Thanks for your thoughts on this... |
All times are GMT +1. The time now is 05:41 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com