ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Runtime error '1004': (https://www.excelbanter.com/excel-programming/273470-runtime-error-1004-a.html)

Capinvest

Runtime error '1004':
 
I have the following code behind a combobox:

Private Sub ClientList_Change()
' this sorts the names alphabetically

Worksheets("Home").Range("C8:C27").Sort _
Key1:=Worksheets("Home").Range("C8"), _
Order1:=xlAscending

End Sub

I am trying to list the contents of c8:c27 alphabetically
in the combobox. This code does that but as soon as I
choose from the combobox I get the following error:

Run-time error '1004':
Sort method of range class failed

I have data in all of the cells that the code is sorting.
I would appericate any help with this matter. Thanks.

Rob Bovey

Runtime error '1004':
 
Try adding:

Worksheets("Home").Range("A1").Select

as the first line of code in your ClientList_Change event procedure.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Capinvest" wrote in message
...
I have the following code behind a combobox:

Private Sub ClientList_Change()
' this sorts the names alphabetically

Worksheets("Home").Range("C8:C27").Sort _
Key1:=Worksheets("Home").Range("C8"), _
Order1:=xlAscending

End Sub

I am trying to list the contents of c8:c27 alphabetically
in the combobox. This code does that but as soon as I
choose from the combobox I get the following error:

Run-time error '1004':
Sort method of range class failed

I have data in all of the cells that the code is sorting.
I would appericate any help with this matter. Thanks.




Capinvest

Runtime error '1004':
 
Thanks, I think that fixed my problem. I appericate it.

-----Original Message-----
Try adding:

Worksheets("Home").Range("A1").Select

as the first line of code in your ClientList_Change event

procedure.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Capinvest" wrote in message
...
I have the following code behind a combobox:

Private Sub ClientList_Change()
' this sorts the names alphabetically

Worksheets("Home").Range("C8:C27").Sort _
Key1:=Worksheets("Home").Range("C8"), _
Order1:=xlAscending

End Sub

I am trying to list the contents of c8:c27

alphabetically
in the combobox. This code does that but as soon as I
choose from the combobox I get the following error:

Run-time error '1004':
Sort method of range class failed

I have data in all of the cells that the code is

sorting.
I would appericate any help with this matter. Thanks.



.



All times are GMT +1. The time now is 12:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com