Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Button Sort Macro Not Working

I have a button macro that opon a worksheet(01-Length of Contract-Rollovers),
selects the sort area(Data), then sort by three criteria(K7, B7, A7). As I
record the macro to do the job it goes smoothly. As soon as I run the
recorded macro or attaches it to a button, it gives me a "Run-time error
'1004'" errorthat states "The sort reference is not valid. Make sure that
it's within the data you want to sort, and the first Sort By box isn't the
same of blank."

Sheets("01-Length of Contract-Rollovers").Select
Application.Goto Reference:="Data"
Selection.Sort Key1:=Range("K7"), Order1:=xlDescending, Key2:=Range("B7") _
, Order2:=xlAscending, Key3:=Range("A7"), Order3:=xlAscending, Header _
:=xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom _
, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Button Sort Macro Not Working

What I gave was an example. "Extra SEARCH criteria"? If you meant extra SORT
criteria just do it the same way with the dot in front of range.



--
Don Guillett
SalesAid Software

"TonyD" wrote in message
...
So far so good. How can I add extra search criteria?

"Don Guillett" wrote:

You went to data( rename to MYdata) but you didn't select it. Try this
IDEA
from anywhere in the workbook. Notice the placement of the dots .
in
front of .range .

Sub gotomydata()
With Sheets("yoursheet")
.Range("mydata").Sort Key1:=.Range("a2")
End With
End Sub

--
Don Guillett
SalesAid Software

"TonyD" wrote in message
...
I have a button macro that opon a worksheet(01-Length of
Contract-Rollovers),
selects the sort area(Data), then sort by three criteria(K7, B7, A7).
As I
record the macro to do the job it goes smoothly. As soon as I run the
recorded macro or attaches it to a button, it gives me a "Run-time
error
'1004'" errorthat states "The sort reference is not valid. Make sure
that
it's within the data you want to sort, and the first Sort By box isn't
the
same of blank."

Sheets("01-Length of Contract-Rollovers").Select
Application.Goto Reference:="Data"
Selection.Sort Key1:=Range("K7"), Order1:=xlDescending,
Key2:=Range("B7")
_
, Order2:=xlAscending, Key3:=Range("A7"), Order3:=xlAscending,
Header
_
:=xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom _
, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal,
DataOption3:=
_
xlSortNormal






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
Using Macro to sort without clicking on macro button dd Excel Discussion (Misc queries) 3 May 3rd 07 06:00 PM
Code created in a Macro not working for a Command Button Amber_D_Laws[_8_] Excel Programming 15 January 13th 06 10:35 PM
sort button,macro, or ? tiffky Excel Programming 3 August 28th 05 06:44 PM
Macro Button Not working on Conversion from 97 to 2002 Abizar Excel Programming 2 October 8th 03 11:40 AM
HELP! Button/Macro or Function has stopped working! ikcizokm Excel Programming 3 September 6th 03 08:51 PM


All times are GMT +1. The time now is 06:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"