Is there a way I can have my sheet autosort selected rows when I re-save the
sheet after adding new data.
Thanks in Advance
Is there a way I can have my sheet autosort selected rows when I re-save the
sheet after adding new data.
Thanks in Advance
You can use a before save event macro
eg
this code goes on the Workbook module sheet and sort columns a & b of the active sheet
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Columns("A:B").Sort Key1:=Range("A1"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub
With that sample I get "Compile Error Expected: type name
You'll have to excuse me as I am relatively new to trying to mess with
excel. Any help appreciated. Thanks in Advance
Here is the code I am trying:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Columns("C").Sort Key1:=Range("C12:C20"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub
"mudraker" <[email protected]> wrote in
message news:[email protected]...
>
> You can use a before save event macro
>
>
>
> eg
>
> this code goes on the Workbook module sheet and sort columns a & b of
> the active sheet
>
> Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
> Boolean)
> Columns("A:B").Sort Key1:=Range("A1"), _
> Order1:=xlAscending, Header:=xlGuess, _
> OrderCustom:=1, MatchCase:=False, _
> Orientation:=xlTopToBottom, _
> DataOption1:=xlSortNormal
> End Sub
>
>
> --
> mudraker
> ------------------------------------------------------------------------
> mudraker's Profile:
> http://www.excelforum.com/member.php...fo&userid=2473
> View this thread: http://www.excelforum.com/showthread...hreadid=535627
>
WylieDude
The following is a Single line command. -I did not notice that it had been word wrapped when I originally posted
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Move Boolean) back to the previous line after Cancel As
Mudraker,
I am a complete beginner at using a macro in excel but found this nice an easy to understand, thanks!
I am trying to sort my data first by column A (Country), then B(City/Town), then C(Place), then D(Link to URL) as you can see I the attachment.
Can you alter the macro you originally posted to incoperate this? It would be great if it did it for the entirety of each column as i plan to add serveral rows
anbs welcome to the forum
Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.
If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.
Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
2. If your question is resolved, mark it SOLVED using the thread tools
3. Click on the star if you think someone helped you
Regards
Ford
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks