Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default sort macro stopped sorting

This sort was working yesterday. This morning it would not sort. I don't
know if it didn't get saved properly. The module compiles. After it
wouldn't sort I had to add a few fields since they changed the speadsheet db.
I just renamed the column numbers of the sort keys that was all I changed.
can you tell me why it doesn't sort. When I run the macro it just sits there
and doesn't move. No response.

Thanks,

-----macro that doesn't sort------


Sub Sort()
'
' Sorts by Item Name, Dept, Status# Macro
Dim rng As Range

' sorts on Dept, & Status since there is only 3 keys available in a sort
With ActiveSheet
Set rng = .Range(.Cells(1, 1), .Cells(Rows.Count, 29).End(xlUp))

rng.Sort key1:=.Cells(2, 16), Order1:=xlAscending, _
key2:=.Cells(2, 19), Order2:=xlAscending, _
key3:=.Cells(2, 3), Order3:=xlAscending, Header:=xlYes, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
End With


End Sub



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default sort macro stopped sorting

I ran it, trying to reproduce the error and had no problems. What do
you mean "sits there"?

Charles

Janis wrote:
This sort was working yesterday. This morning it would not sort. I don't
know if it didn't get saved properly. The module compiles. After it
wouldn't sort I had to add a few fields since they changed the speadsheet db.
I just renamed the column numbers of the sort keys that was all I changed.
can you tell me why it doesn't sort. When I run the macro it just sits there
and doesn't move. No response.

Thanks,

-----macro that doesn't sort------


Sub Sort()
'
' Sorts by Item Name, Dept, Status# Macro
Dim rng As Range

' sorts on Dept, & Status since there is only 3 keys available in a sort
With ActiveSheet
Set rng = .Range(.Cells(1, 1), .Cells(Rows.Count, 29).End(xlUp))

rng.Sort key1:=.Cells(2, 16), Order1:=xlAscending, _
key2:=.Cells(2, 19), Order2:=xlAscending, _
key3:=.Cells(2, 3), Order3:=xlAscending, Header:=xlYes, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
End With


End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default sort macro stopped sorting

"sits there = doesn't move, i.e. it used to kind of shake a little as it
moved all the fields around. Now it doesn't move at all. The cursor doesn't
move, nothing moves.

"Die_Another_Day" wrote:

I ran it, trying to reproduce the error and had no problems. What do
you mean "sits there"?

Charles

Janis wrote:
This sort was working yesterday. This morning it would not sort. I don't
know if it didn't get saved properly. The module compiles. After it
wouldn't sort I had to add a few fields since they changed the speadsheet db.
I just renamed the column numbers of the sort keys that was all I changed.
can you tell me why it doesn't sort. When I run the macro it just sits there
and doesn't move. No response.

Thanks,

-----macro that doesn't sort------


Sub Sort()
'
' Sorts by Item Name, Dept, Status# Macro
Dim rng As Range

' sorts on Dept, & Status since there is only 3 keys available in a sort
With ActiveSheet
Set rng = .Range(.Cells(1, 1), .Cells(Rows.Count, 29).End(xlUp))

rng.Sort key1:=.Cells(2, 16), Order1:=xlAscending, _
key2:=.Cells(2, 19), Order2:=xlAscending, _
key3:=.Cells(2, 3), Order3:=xlAscending, Header:=xlYes, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
End With


End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default sort macro stopped sorting

what is in column 29. If there is no data there, then there is your
huckleberry.

Add this to check

Set rng = .Range(.Cells(1, 1), .Cells(Rows.Count, 29).End(xlUp))
msgbox rng.Address

if rng just refers to the first row or less than what you expected . . .

--
Regards,
Tom Ogilvy


"Janis" wrote:

This sort was working yesterday. This morning it would not sort. I don't
know if it didn't get saved properly. The module compiles. After it
wouldn't sort I had to add a few fields since they changed the speadsheet db.
I just renamed the column numbers of the sort keys that was all I changed.
can you tell me why it doesn't sort. When I run the macro it just sits there
and doesn't move. No response.

Thanks,

-----macro that doesn't sort------


Sub Sort()
'
' Sorts by Item Name, Dept, Status# Macro
Dim rng As Range

' sorts on Dept, & Status since there is only 3 keys available in a sort
With ActiveSheet
Set rng = .Range(.Cells(1, 1), .Cells(Rows.Count, 29).End(xlUp))

rng.Sort key1:=.Cells(2, 16), Order1:=xlAscending, _
key2:=.Cells(2, 19), Order2:=xlAscending, _
key3:=.Cells(2, 3), Order3:=xlAscending, Header:=xlYes, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
End With


End Sub



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default sort macro stopped sorting

Since the database changed did the number of columns change? If so your 29
could now be incorrect. Try this if the data source could be changing. It
dynamically determines the number of columns

Set rng = .Range(.Cells(1, 1), .Cells(Rows.Count, .cells(1,
columns.count).end(xlToLeft)).End(xlUp))

--
HTH...

Jim Thomlinson


"Janis" wrote:

This sort was working yesterday. This morning it would not sort. I don't
know if it didn't get saved properly. The module compiles. After it
wouldn't sort I had to add a few fields since they changed the speadsheet db.
I just renamed the column numbers of the sort keys that was all I changed.
can you tell me why it doesn't sort. When I run the macro it just sits there
and doesn't move. No response.

Thanks,

-----macro that doesn't sort------


Sub Sort()
'
' Sorts by Item Name, Dept, Status# Macro
Dim rng As Range

' sorts on Dept, & Status since there is only 3 keys available in a sort
With ActiveSheet
Set rng = .Range(.Cells(1, 1), .Cells(Rows.Count, 29).End(xlUp))

rng.Sort key1:=.Cells(2, 16), Order1:=xlAscending, _
key2:=.Cells(2, 19), Order2:=xlAscending, _
key3:=.Cells(2, 3), Order3:=xlAscending, Header:=xlYes, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
End With


End Sub





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default sort macro stopped sorting

Yes the number of columns changed. I didn't know Excel had to have data in
it to count it. I assumed it could count either way. Thanks, for the
expandable column counter!

"Jim Thomlinson" wrote:

Since the database changed did the number of columns change? If so your 29
could now be incorrect. Try this if the data source could be changing. It
dynamically determines the number of columns

Set rng = .Range(.Cells(1, 1), .Cells(Rows.Count, .cells(1,
columns.count).end(xlToLeft)).End(xlUp))

--
HTH...

Jim Thomlinson


"Janis" wrote:

This sort was working yesterday. This morning it would not sort. I don't
know if it didn't get saved properly. The module compiles. After it
wouldn't sort I had to add a few fields since they changed the speadsheet db.
I just renamed the column numbers of the sort keys that was all I changed.
can you tell me why it doesn't sort. When I run the macro it just sits there
and doesn't move. No response.

Thanks,

-----macro that doesn't sort------


Sub Sort()
'
' Sorts by Item Name, Dept, Status# Macro
Dim rng As Range

' sorts on Dept, & Status since there is only 3 keys available in a sort
With ActiveSheet
Set rng = .Range(.Cells(1, 1), .Cells(Rows.Count, 29).End(xlUp))

rng.Sort key1:=.Cells(2, 16), Order1:=xlAscending, _
key2:=.Cells(2, 19), Order2:=xlAscending, _
key3:=.Cells(2, 3), Order3:=xlAscending, Header:=xlYes, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
End With


End Sub



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default sort macro stopped sorting

I love the error checking message box. Thanks.
That was it, the column on the right had data in it but
they added two fields, but they took out some fields also.
It was just the wrong number on the right.

"Janis" wrote:

This sort was working yesterday. This morning it would not sort. I don't
know if it didn't get saved properly. The module compiles. After it
wouldn't sort I had to add a few fields since they changed the speadsheet db.
I just renamed the column numbers of the sort keys that was all I changed.
can you tell me why it doesn't sort. When I run the macro it just sits there
and doesn't move. No response.

Thanks,

-----macro that doesn't sort------


Sub Sort()
'
' Sorts by Item Name, Dept, Status# Macro
Dim rng As Range

' sorts on Dept, & Status since there is only 3 keys available in a sort
With ActiveSheet
Set rng = .Range(.Cells(1, 1), .Cells(Rows.Count, 29).End(xlUp))

rng.Sort key1:=.Cells(2, 16), Order1:=xlAscending, _
key2:=.Cells(2, 19), Order2:=xlAscending, _
key3:=.Cells(2, 3), Order3:=xlAscending, Header:=xlYes, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
End With


End Sub



Reply
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
Spreadsheet macro stopped working! Anders[_2_] Excel Discussion (Misc queries) 5 November 22nd 09 05:28 PM
Macro stopped working Ed Davis[_2_] Excel Discussion (Misc queries) 5 October 7th 09 11:46 PM
vba sorting stopped working Papa Jonah Excel Programming 6 April 19th 05 01:03 PM
Macro Execution Stopped Tom Ogilvy Excel Programming 1 June 2nd 04 08:26 PM
why did the macro stopped working? Martyn Excel Programming 12 April 21st 04 03:29 PM


All times are GMT +1. The time now is 08:13 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"