Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / June 2007

Tip: Looking for answers? Try searching our database.

sort macro help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dzelnio - 20 Jun 2007 20:13 GMT
Cells.Select
   Selection.Sort Key1:=Range("E1"), Order1:=xlDescending,
Header:=xlNo, _
       OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub

Anyone know why this macro would stop everytime?

dzelnio
Gord Dibben - 20 Jun 2007 20:36 GMT
Sub foo()
   Cells.Select
   Selection.Sort Key1:=Range("E1"), Order1:=xlDescending, Header:=xlNo, _
       OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub

Works for me.

What do you mean by "stop"?  Any error message or?

Gord Dibben  MS Excel MVP

>    Cells.Select
>    Selection.Sort Key1:=Range("E1"), Order1:=xlDescending,
[quoted text clipped - 5 lines]
>
>dzelnio
dzelnio - 20 Jun 2007 21:28 GMT
I get a dialog box that says "sort method of range class failed."

Any ideas?

> Sub foo()
>     Cells.Select
[quoted text clipped - 17 lines]
>
> >dzelnio
dzelnio - 20 Jun 2007 21:37 GMT
I might need to refer to the worksheet in the code.  It is called
"Details".
How do I make the script select the worksheet called "Details" then do
the sorting?

Dave

> I get a dialog box that says "sort method of range class failed."
>
[quoted text clipped - 21 lines]
>
> > >dzelnio
Gord Dibben - 20 Jun 2007 21:49 GMT
If that sheet is not the activesheet then yes...........you must refer to it.

Sub foo()
With Sheets("Details")
    Cells.Select
    Selection.Sort Key1:=Range("E1"), Order1:=xlDescending, Header:=xlNo, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With
End Sub

Gord

>I might need to refer to the worksheet in the code.  It is called
>"Details".
[quoted text clipped - 28 lines]
>>
>> > >dzelnio
dzelnio - 20 Jun 2007 22:08 GMT
Where syntax error on this script...

Sub Sortdescending()

With Sheets("Details")
    Cells.Select
    Selection.Sort Key1:=Range("E1"), Order1:=xlDescending,
Header:=xlNo, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With
End Sub

=====

> If that sheet is not the activesheet then yes...........you must refer to it.
>
[quoted text clipped - 40 lines]
>
> >> > >dzelnio
Dave Peterson - 20 Jun 2007 22:15 GMT
How about:

Sub foo()
With Sheets("Details")
   with .usedrange  'column A to whatever?
      .cells.sort Key1:=.columns(5), Order1:=xlDescending, Header:=xlNo, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
   end with
end with
End Sub

> Where syntax error on this script...
>
[quoted text clipped - 54 lines]
> >
> > >> > >dzelnio

Signature

Dave Peterson

dzelnio - 20 Jun 2007 22:23 GMT
The syntax error lands on Sub foo()
??

> How about:
>
[quoted text clipped - 69 lines]
>
> Dave Peterson
Dave Peterson - 20 Jun 2007 22:30 GMT
Delete that line and then retype that line.

You may have extra (invisible) characters that you can't see.

> The syntax error lands on Sub foo()
> ??
[quoted text clipped - 72 lines]
> >
> > Dave Peterson

Signature

Dave Peterson

Gord Dibben - 20 Jun 2007 22:27 GMT
Which line is highlighted when you get the error?

That should tell you something.

Works for me as written so don't get any syntax errors to look for.

This line is all one line...........should show in red font if you have it in
your module as two or three lines without a line continuation character as your
post shows

Selection.Sort Key1:=Range("E1"),Order1:=xlDescending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

Gord

>Where syntax error on this script...
>
[quoted text clipped - 54 lines]
>>
>> >> > >dzelnio
Dave Peterson - 20 Jun 2007 23:02 GMT
You'd also want to select that worksheet:

With Sheets("Details")
    .select
    Cells.Select

> Which line is highlighted when you get the error?
>
[quoted text clipped - 69 lines]
> >>
> >> >> > >dzelnio

Signature

Dave Peterson

Gord Dibben - 20 Jun 2007 23:12 GMT
Why select it?

Gord

>You'd also want to select that worksheet:
>
[quoted text clipped - 75 lines]
>> >>
>> >> >> > >dzelnio
Dave Peterson - 20 Jun 2007 23:17 GMT
If details isn't the activesheet, then
cells.select will be selecting the cells on whatever sheet is active.
And selection.sort will be sorting the selection on whatever sheet is active.

But I wouldn't select it either.  I'd just make sure every range object is
qualified with worksheets("details").

> Why select it?
>
[quoted text clipped - 79 lines]
> >> >>
> >> >> >> > >dzelnio

Signature

Dave Peterson

Gord Dibben - 20 Jun 2007 23:39 GMT
So right.

I was testing with Details sheet active so did not notice.

It's the new drugs<g>

Gord

>If details isn't the activesheet, then
>cells.select will be selecting the cells on whatever sheet is active.
[quoted text clipped - 86 lines]
>> >> >>
>> >> >> >> > >dzelnio
Peo Sjoblom - 20 Jun 2007 23:55 GMT
Cialis?

Peo

> It's the new drugs<g>
>
[quoted text clipped - 110 lines]
>>> >> >>
>>> >> >> >> > >dzelnio
Gord Dibben - 21 Jun 2007 00:27 GMT
I wish it were that simple.

Gord

>Cialis?
>
[quoted text clipped - 114 lines]
>>>> >> >>
>>>> >> >> >> > >dzelnio
dzelnio - 21 Jun 2007 16:17 GMT
The macro is working for now.  It is part of a larger script, so I'll
be testing it for a couple of days...

This process has taken me way too many hours.  You guys probably could
have done it in your sleep.

Thanks for the help!

dzelnio

> I wish it were that simple.
>
[quoted text clipped - 118 lines]
>
> >>>> >> >> >> > >dzelnio
Peo Sjoblom - 21 Jun 2007 16:39 GMT
Are you still smoking?

Peo

>I wish it were that simple.
>
[quoted text clipped - 125 lines]
>>>>> >> >>
>>>>> >> >> >> > >dzelnio
Gord Dibben - 21 Jun 2007 17:35 GMT
Didn't smoke for 10 months last year but started again in December

Gord

>Are you still smoking?
>
[quoted text clipped - 129 lines]
>>>>>> >> >>
>>>>>> >> >> >> > >dzelnio
Gord Dibben - 20 Jun 2007 23:56 GMT
The old ones were not much better but I'm sure you will drop that in
somewhere<g>

Gord

>So right.
>
[quoted text clipped - 3 lines]
>
>Gord

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.