OK... first off, Thank you so much for your speedy response!
Second... I copied in this partial code into the VB editor on
quot;ThisWorkbookquot;... now (and I'm sorry if you feel you have to spoon feed me...
I get scared of code) Say my worksheet has a column with a header of
quot;Projectquot; in column D and column E has quot;Assignmentquot;... I would like it to
sort primary on column D and secondary on column E. How in the world to I do
this? I'm a good student, just one that has avoided learning any type of
programing or code for years and now it's coming back to bite me.
Thanks so much for your expertise and patience!!!
quot;Chip Pearsonquot; wrote:
gt; Open the ThisWorkbook module, and use the BeforeSave event
gt; procedure.
gt;
gt; Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
gt; Cancel As Boolean)
gt; '
gt; ' your sort code here
gt; '
gt; End Sub
gt;
gt;
gt; --
gt; Cordially,
gt; Chip Pearson
gt; Microsoft MVP - Excel
gt; Pearson Software Consulting, LLC
gt; www.cpearson.com
gt;
gt;
gt;
gt;
gt; quot;KDGquot; gt; wrote in message
gt; news
gt; gt;I have a shared file that is being used by some rather
gt; gt;inexperienced Excel
gt; gt; users. This file will expand with extended use as each user
gt; gt; enters their
gt; gt; data. In order to make it easier for them to use, I'm trying to
gt; gt; automate some
gt; gt; things.
gt; gt;
gt; gt; Is there a way... and I'm sure there is, I'm just not
gt; gt; experienced enough to
gt; gt; know how... that I can have my file automatically sort on a
gt; gt; particular column
gt; gt; when the user goes to save it? I'm thinking that this must be
gt; gt; either a macro
gt; gt; or VBA or whatever, but I am rather a novice in this area.
gt;
gt;
gt;
In the Workbook_BeforeSave procedure, use
Dim WS As Worksheet
Set WS = Worksheets(quot;Sheet1quot;) 'lt;lt; change if required
With WS.UsedRange
.Sort key1:=.Range(quot;D1quot;), order1:=xlAscending,
key2:=.Range(quot;E1quot;), _
order2:=xlAscending
End With--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
quot;KDGquot; gt; wrote in message
...
gt; OK... first off, Thank you so much for your speedy response!
gt; Second... I copied in this partial code into the VB editor on
gt; quot;ThisWorkbookquot;... now (and I'm sorry if you feel you have to
gt; spoon feed me...
gt; I get scared of code) Say my worksheet has a column with a
gt; header of
gt; quot;Projectquot; in column D and column E has quot;Assignmentquot;... I would
gt; like it to
gt; sort primary on column D and secondary on column E. How in the
gt; world to I do
gt; this? I'm a good student, just one that has avoided learning
gt; any type of
gt; programing or code for years and now it's coming back to bite
gt; me.
gt;
gt; Thanks so much for your expertise and patience!!!
gt;
gt; quot;Chip Pearsonquot; wrote:
gt;
gt;gt; Open the ThisWorkbook module, and use the BeforeSave event
gt;gt; procedure.
gt;gt;
gt;gt; Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
gt;gt; Cancel As Boolean)
gt;gt; '
gt;gt; ' your sort code here
gt;gt; '
gt;gt; End Sub
gt;gt;
gt;gt;
gt;gt; --
gt;gt; Cordially,
gt;gt; Chip Pearson
gt;gt; Microsoft MVP - Excel
gt;gt; Pearson Software Consulting, LLC
gt;gt; www.cpearson.com
gt;gt;
gt;gt;
gt;gt;
gt;gt;
gt;gt; quot;KDGquot; gt; wrote in message
gt;gt; news
gt;gt; gt;I have a shared file that is being used by some rather
gt;gt; gt;inexperienced Excel
gt;gt; gt; users. This file will expand with extended use as each user
gt;gt; gt; enters their
gt;gt; gt; data. In order to make it easier for them to use, I'm trying
gt;gt; gt; to
gt;gt; gt; automate some
gt;gt; gt; things.
gt;gt; gt;
gt;gt; gt; Is there a way... and I'm sure there is, I'm just not
gt;gt; gt; experienced enough to
gt;gt; gt; know how... that I can have my file automatically sort on a
gt;gt; gt; particular column
gt;gt; gt; when the user goes to save it? I'm thinking that this must
gt;gt; gt; be
gt;gt; gt; either a macro
gt;gt; gt; or VBA or whatever, but I am rather a novice in this area.
gt;gt;
gt;gt;
gt;gt;
I'll eventually get this... OK... it's sorting. That's GREAT!!! However... do
I lock the top row in place before I start this? Right now my column headers
are sorting in with all the other data. Am I on the right track?
Also, this is a multi sheet document (one sheet for each user). In the code,
I'm assuming I copy that part of the code down and put the appropriate
quot;sheetquot; name in the appropriate spot (I'll try it and see if it works).
Again! Thanks sooooo much! You're really saving my life and making my boss
very happy!
quot;Chip Pearsonquot; wrote:
gt; In the Workbook_BeforeSave procedure, use
gt;
gt; Dim WS As Worksheet
gt; Set WS = Worksheets(quot;Sheet1quot;) 'lt;lt; change if required
gt; With WS.UsedRange
gt; .Sort key1:=.Range(quot;D1quot;), order1:=xlAscending,
gt; key2:=.Range(quot;E1quot;), _
gt; order2:=xlAscending
gt; End With
gt;
gt;
gt; --
gt; Cordially,
gt; Chip Pearson
gt; Microsoft MVP - Excel
gt; Pearson Software Consulting, LLC
gt; www.cpearson.com
gt;
gt;
gt;
gt; quot;KDGquot; gt; wrote in message
gt; ...
gt; gt; OK... first off, Thank you so much for your speedy response!
gt; gt; Second... I copied in this partial code into the VB editor on
gt; gt; quot;ThisWorkbookquot;... now (and I'm sorry if you feel you have to
gt; gt; spoon feed me...
gt; gt; I get scared of code) Say my worksheet has a column with a
gt; gt; header of
gt; gt; quot;Projectquot; in column D and column E has quot;Assignmentquot;... I would
gt; gt; like it to
gt; gt; sort primary on column D and secondary on column E. How in the
gt; gt; world to I do
gt; gt; this? I'm a good student, just one that has avoided learning
gt; gt; any type of
gt; gt; programing or code for years and now it's coming back to bite
gt; gt; me.
gt; gt;
gt; gt; Thanks so much for your expertise and patience!!!
gt; gt;
gt; gt; quot;Chip Pearsonquot; wrote:
gt; gt;
gt; gt;gt; Open the ThisWorkbook module, and use the BeforeSave event
gt; gt;gt; procedure.
gt; gt;gt;
gt; gt;gt; Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
gt; gt;gt; Cancel As Boolean)
gt; gt;gt; '
gt; gt;gt; ' your sort code here
gt; gt;gt; '
gt; gt;gt; End Sub
gt; gt;gt;
gt; gt;gt;
gt; gt;gt; --
gt; gt;gt; Cordially,
gt; gt;gt; Chip Pearson
gt; gt;gt; Microsoft MVP - Excel
gt; gt;gt; Pearson Software Consulting, LLC
gt; gt;gt; www.cpearson.com
gt; gt;gt;
gt; gt;gt;
gt; gt;gt;
gt; gt;gt;
gt; gt;gt; quot;KDGquot; gt; wrote in message
gt; gt;gt; news
gt; gt;gt; gt;I have a shared file that is being used by some rather
gt; gt;gt; gt;inexperienced Excel
gt; gt;gt; gt; users. This file will expand with extended use as each user
gt; gt;gt; gt; enters their
gt; gt;gt; gt; data. In order to make it easier for them to use, I'm trying
gt; gt;gt; gt; to
gt; gt;gt; gt; automate some
gt; gt;gt; gt; things.
gt; gt;gt; gt;
gt; gt;gt; gt; Is there a way... and I'm sure there is, I'm just not
gt; gt;gt; gt; experienced enough to
gt; gt;gt; gt; know how... that I can have my file automatically sort on a
gt; gt;gt; gt; particular column
gt; gt;gt; gt; when the user goes to save it? I'm thinking that this must
gt; gt;gt; gt; be
gt; gt;gt; gt; either a macro
gt; gt;gt; gt; or VBA or whatever, but I am rather a novice in this area.
gt; gt;gt;
gt; gt;gt;
gt; gt;gt;
gt;
gt;
gt;
Another thing... it seems to be sorting on the first key, but I'm getting an
error on the second. quot;Run time error: Sort method of range class failedquot; is
what it says.
Any ideas???
quot;Chip Pearsonquot; wrote:
gt; In the Workbook_BeforeSave procedure, use
gt;
gt; Dim WS As Worksheet
gt; Set WS = Worksheets(quot;Sheet1quot;) 'lt;lt; change if required
gt; With WS.UsedRange
gt; .Sort key1:=.Range(quot;D1quot;), order1:=xlAscending,
gt; key2:=.Range(quot;E1quot;), _
gt; order2:=xlAscending
gt; End With
gt;
gt;
gt; --
gt; Cordially,
gt; Chip Pearson
gt; Microsoft MVP - Excel
gt; Pearson Software Consulting, LLC
gt; www.cpearson.com
gt;
gt;
gt;
gt; quot;KDGquot; gt; wrote in message
gt; ...
gt; gt; OK... first off, Thank you so much for your speedy response!
gt; gt; Second... I copied in this partial code into the VB editor on
gt; gt; quot;ThisWorkbookquot;... now (and I'm sorry if you feel you have to
gt; gt; spoon feed me...
gt; gt; I get scared of code) Say my worksheet has a column with a
gt; gt; header of
gt; gt; quot;Projectquot; in column D and column E has quot;Assignmentquot;... I would
gt; gt; like it to
gt; gt; sort primary on column D and secondary on column E. How in the
gt; gt; world to I do
gt; gt; this? I'm a good student, just one that has avoided learning
gt; gt; any type of
gt; gt; programing or code for years and now it's coming back to bite
gt; gt; me.
gt; gt;
gt; gt; Thanks so much for your expertise and patience!!!
gt; gt;
gt; gt; quot;Chip Pearsonquot; wrote:
gt; gt;
gt; gt;gt; Open the ThisWorkbook module, and use the BeforeSave event
gt; gt;gt; procedure.
gt; gt;gt;
gt; gt;gt; Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
gt; gt;gt; Cancel As Boolean)
gt; gt;gt; '
gt; gt;gt; ' your sort code here
gt; gt;gt; '
gt; gt;gt; End Sub
gt; gt;gt;
gt; gt;gt;
gt; gt;gt; --
gt; gt;gt; Cordially,
gt; gt;gt; Chip Pearson
gt; gt;gt; Microsoft MVP - Excel
gt; gt;gt; Pearson Software Consulting, LLC
gt; gt;gt; www.cpearson.com
gt; gt;gt;
gt; gt;gt;
gt; gt;gt;
gt; gt;gt;
gt; gt;gt; quot;KDGquot; gt; wrote in message
gt; gt;gt; news
gt; gt;gt; gt;I have a shared file that is being used by some rather
gt; gt;gt; gt;inexperienced Excel
gt; gt;gt; gt; users. This file will expand with extended use as each user
gt; gt;gt; gt; enters their
gt; gt;gt; gt; data. In order to make it easier for them to use, I'm trying
gt; gt;gt; gt; to
gt; gt;gt; gt; automate some
gt; gt;gt; gt; things.
gt; gt;gt; gt;
gt; gt;gt; gt; Is there a way... and I'm sure there is, I'm just not
gt; gt;gt; gt; experienced enough to
gt; gt;gt; gt; know how... that I can have my file automatically sort on a
gt; gt;gt; gt; particular column
gt; gt;gt; gt; when the user goes to save it? I'm thinking that this must
gt; gt;gt; gt; be
gt; gt;gt; gt; either a macro
gt; gt;gt; gt; or VBA or whatever, but I am rather a novice in this area.
gt; gt;gt;
gt; gt;gt;
gt; gt;gt;
gt;
gt;
gt;
- Sep 10 Mon 2007 20:39
Macro to Sort automatically when file/save is selected
close
全站熱搜
留言列表
發表留言