Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I tryed that and now I get the following error:
Compile error Syntax error I would appericiate any further help. Thanks. -----Original Message----- Change Worksheets("Home").Range("C8:C27").Sort Key1: = Worksheets("Home").Range("C8") XlSortOrder.xlAscending to Worksheets("Home").Range("C8:C27").Sort Key1: = Worksheets("Home").Range("C8"), Order1:= xlAscending -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Capinvest" wrote in message ... I am trying to sort a combobox alphabetically in excel using vba. I have the following code behind the combobox: Private Sub ClientList_Change() ' this sorts the names alphabetically Worksheets("Home").Range("C8:C27").Sort Key1: = Worksheets("Home").Range("C8") XlSortOrder.xlAscending End Sub I get an error everytime I try to run it. The error says: Compile error: Expected:expression I would appericate any help with this issue. . |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
is the code really on three lines. If so, you would use line continuation
characters: Worksheets("Home").Range("C8:C27").Sort _ Key1: = Worksheets("Home").Range("C8"), _ Order1:= xlAscending Also, you might need to clear the rowsource/listfillrange of the control before sorting Public bBlockEvents as Boolean Assuming on a worksheet, for a userform change listfillrange to rowsource Private Sub ClientList_Change() ' this sorts the names alphabetically if bBlockEvents then exit sub On Error goto ErrHandler bBlockEvents = True ClientList.ListFillRange = "" Worksheets("Home").Range("C8:C27").Sort _ Key1: = Worksheets("Home").Range("C8"), _ Order1:= xlAscending ClientList.ListFillRange = "Home!C8:C27" ErrHandler: bBlockEvents = False End Sub Still, I am not sure why you would sort the list on a change event. Also, making changes like this in the change event (which would trigger a change event) can be troublesome. The above is untested and may not work anyway. -- Regards, Tom Ogilvy "Capinvest" wrote in message ... I tryed that and now I get the following error: Compile error Syntax error I would appericiate any further help. Thanks. -----Original Message----- Change Worksheets("Home").Range("C8:C27").Sort Key1: = Worksheets("Home").Range("C8") XlSortOrder.xlAscending to Worksheets("Home").Range("C8:C27").Sort Key1: = Worksheets("Home").Range("C8"), Order1:= xlAscending -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Capinvest" wrote in message ... I am trying to sort a combobox alphabetically in excel using vba. I have the following code behind the combobox: Private Sub ClientList_Change() ' this sorts the names alphabetically Worksheets("Home").Range("C8:C27").Sort Key1: = Worksheets("Home").Range("C8") XlSortOrder.xlAscending End Sub I get an error everytime I try to run it. The error says: Compile error: Expected:expression I would appericate any help with this issue. . |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for your help, everything works great.
-----Original Message----- is the code really on three lines. If so, you would use line continuation characters: Worksheets("Home").Range("C8:C27").Sort _ Key1: = Worksheets("Home").Range("C8"), _ Order1:= xlAscending Also, you might need to clear the rowsource/listfillrange of the control before sorting Public bBlockEvents as Boolean Assuming on a worksheet, for a userform change listfillrange to rowsource Private Sub ClientList_Change() ' this sorts the names alphabetically if bBlockEvents then exit sub On Error goto ErrHandler bBlockEvents = True ClientList.ListFillRange = "" Worksheets("Home").Range("C8:C27").Sort _ Key1: = Worksheets("Home").Range("C8"), _ Order1:= xlAscending ClientList.ListFillRange = "Home!C8:C27" ErrHandler: bBlockEvents = False End Sub Still, I am not sure why you would sort the list on a change event. Also, making changes like this in the change event (which would trigger a change event) can be troublesome. The above is untested and may not work anyway. -- Regards, Tom Ogilvy "Capinvest" wrote in message ... I tryed that and now I get the following error: Compile error Syntax error I would appericiate any further help. Thanks. -----Original Message----- Change Worksheets("Home").Range("C8:C27").Sort Key1: = Worksheets("Home").Range("C8") XlSortOrder.xlAscending to Worksheets("Home").Range("C8:C27").Sort Key1: = Worksheets("Home").Range("C8"), Order1:= xlAscending -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Capinvest" wrote in message ... I am trying to sort a combobox alphabetically in excel using vba. I have the following code behind the combobox: Private Sub ClientList_Change() ' this sorts the names alphabetically Worksheets("Home").Range("C8:C27").Sort Key1: = Worksheets("Home").Range("C8") XlSortOrder.xlAscending End Sub I get an error everytime I try to run it. The error says: Compile error: Expected:expression I would appericate any help with this issue. . . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
value expression | Excel Worksheet Functions | |||
need help with expression | Excel Discussion (Misc queries) | |||
Expression | New Users to Excel | |||
Expected end of Statement | Excel Worksheet Functions | |||
Expression for Macro - help | Excel Discussion (Misc queries) |