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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
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 |