A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Need help. Sorting on save in multi-sheet workbook.



 
 
Thread Tools Display Modes
  #1  
Old December 21st, 2005, 02:21 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Need help. Sorting on save in multi-sheet workbook.

Yesterday, someone was wonderful enough to help me thus far, however, I'm
still having some problems. Below is the code I have that takes the
individual sheets and sorts them when the file is saved. I am getting an
error on the sort keys that 1) sorts the entire column, including the header,
which I don't want sorted into the data, and 2) stops after sorting the first
key and doesn't continue.

Also need to know if the way it is set up will continue on to each worksheet
in the workbook.... I hope so.

I appreciate any help... I'm hoping to have this up and running this week to
please my co-workers and boss.
----


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
'
Dim WS As Worksheet
Set WS = Worksheets("Kathryn")
With WS.UsedRange

..Sort key1:=.Range("Project"), order1:=xlAscending
..Sort key2:=.Range("Assignment"), order2:=xlAscending
End With

Set WS = Worksheets("Dave")
With WS.UsedRange

..Sort key1:=.Range("Project"), order1:=xlAscending
..Sort key2:=.Range("Assignment"), order2:=xlAscending
End With

Set WS = Worksheets("Ann")
With WS.UsedRange

..Sort key1:=.Range("Project"), order1:=xlAscending
..Sort key2:=.Range("Assignment"), order2:=xlAscending
End With

End Sub


  #2  
Old December 21st, 2005, 04:14 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Need help. Sorting on save in multi-sheet workbook.

On Wed, 21 Dec 2005 06:21:02 -0800, KDG wrote:

Yesterday, someone was wonderful enough to help me thus far, however, I'm
still having some problems. Below is the code I have that takes the
individual sheets and sorts them when the file is saved. I am getting an
error on the sort keys that 1) sorts the entire column, including the header,
which I don't want sorted into the data, and 2) stops after sorting the first
key and doesn't continue.

Also need to know if the way it is set up will continue on to each worksheet
in the workbook.... I hope so.

I appreciate any help... I'm hoping to have this up and running this week to
please my co-workers and boss.
----

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
'
Dim WS As Worksheet
Set WS = Worksheets("Kathryn")
With WS.UsedRange

.Sort key1:=.Range("Project"), order1:=xlAscending
.Sort key2:=.Range("Assignment"), order2:=xlAscending
End With

Set WS = Worksheets("Dave")
With WS.UsedRange

.Sort key1:=.Range("Project"), order1:=xlAscending
.Sort key2:=.Range("Assignment"), order2:=xlAscending
End With

Set WS = Worksheets("Ann")
With WS.UsedRange

.Sort key1:=.Range("Project"), order1:=xlAscending
.Sort key2:=.Range("Assignment"), order2:=xlAscending
End With

End Sub


You have posted this message to the wrong newsgroup.
The access in this groups name refers to Microsoft Access, a database
program.
Please repost to the correct Excel newsgroup. I would suggest you
include your Windows and Office/Excel version number in the message.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving one sheet within a workbook David Vollmer General Discussion 2 September 14th, 2005 06:04 PM
Using a relative SHEET reference for source data in a chart James Charts and Charting 6 August 16th, 2005 05:07 PM
Use Sheet CodeNames to Select Sheet in Different Workbook Randy General Discussion 1 June 10th, 2005 12:17 AM
Startup defaul sheet in a workbook GeoN Setting up and Configuration 1 February 11th, 2004 06:51 PM


All times are GMT +1. The time now is 11:26 PM.


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