LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Sort Problem using a button

Hi,

Have you tried something like this ?


'-------------------
Sub Main_Button1()
For a = 2 To Worksheets.Count
Sort Worksheets(a)
Next
End Sub
'-------------------

Private Sub Sort(Sh As Worksheet)
With Sh
With .Range("A2:D14")
.Sort Key1:=.Item(1), Order1:=xlAscending, _
Header:=xlNo, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
End With
End Sub
'-------------------



"caldog" a écrit dans le message de groupe de
discussion : ...
I have several worksheets, that I need to sort. My idea was to put a button
on what I call my 'input page' and sort each of these pages. But I get the
error: "Run-Time Error 1004: 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 or blank."

Now on sheet 1 is where the button is. Information that is to be sorted is
on sheet2, sheet3 sheet 4 and etc.

Sort code is:

Private Sub Sort1()

ActiveSheet.Range("A2:D14").Select
Selection.Sort Key1:=Range("A2"),Order:=xlAscending, Header:=xlNo,
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopTobottom,
DataOption1:=xlSortNormal

End Sub


Private Sub Main Button1()
'This is tied to main button on sheet 1
Sheets("Sheet 2").Select

Call Sort1

Sheets("Sheet 3").Select

Call Sort 1
End sub


Each range in each sheet will be the same. The error comes when I try to
call Sort1.

Can you folks give some help in letting me know what I am doing wrong.

Steve

 
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
sort button JeffK Excel Programming 2 December 6th 08 01:52 PM
Sort Button John Gregory Excel Discussion (Misc queries) 2 June 25th 08 08:27 PM
Automated sort button Bwells Excel Discussion (Misc queries) 4 September 20th 07 03:22 PM
sort button,macro, or ? tiffky Excel Programming 3 August 28th 05 06:44 PM
Add Sort button Mike Excel Programming 2 December 17th 03 12:42 AM


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