LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Expected:expression

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.



.



.

 
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
value expression RayB Excel Worksheet Functions 7 January 17th 07 09:57 PM
need help with expression Peterpunkin Excel Discussion (Misc queries) 5 May 4th 06 05:56 PM
Expression gudway New Users to Excel 3 May 4th 06 01:12 PM
Expected end of Statement FIRSTROUNDKO via OfficeKB.com Excel Worksheet Functions 2 April 11th 06 11:59 AM
Expression for Macro - help Pasmatos Excel Discussion (Misc queries) 4 November 28th 05 07:02 PM


All times are GMT +1. The time now is 03:37 PM.

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"