+ Reply to Thread
Results 1 to 4 of 4

auto sort worksheet by date

Hybrid View

kcrush auto sort worksheet by date 11-23-2011, 12:08 PM
Domski Re: auto sort worksheet by... 11-23-2011, 12:13 PM
kcrush Re: auto sort worksheet by... 11-23-2011, 12:28 PM
kcrush Re: auto sort worksheet by... 02-02-2012, 01:34 PM
  1. #1
    Registered User
    Join Date
    11-23-2011
    Location
    Chicago, Illinois
    MS-Off Ver
    Excel 2007
    Posts
    7

    auto sort worksheet by date

    Hi,
    I am trying to have excel autimatically sort a worksheet with columns A-F by the dates in column E, oldest to newest. I want to be able to add information in new rows and have it sort with the rest of the worksheet when I save.

    Thanks

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: auto sort worksheet by date

    Try this (change sheet name):

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    
        Sheets("Sheet1").Range("A1").CurrentRegion.Sort Key1:=Range("E1"), Order1:=xlAscending, Header:= _
            xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
            DataOption1:=xlSortTextAsNumbers
    
    End Sub

    The code needs to go on the ThisWorkbook page of your workbook's VBA project.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    11-23-2011
    Location
    Chicago, Illinois
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: auto sort worksheet by date

    Thanks so much!

  4. #4
    Registered User
    Join Date
    11-23-2011
    Location
    Chicago, Illinois
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: auto sort worksheet by date

    I also would like to make it so when I enter any data in, it automatically copies to sheet2, but I don't want sheet 2 to auto sort column E as sheet1 does.

    Can someone help me out with this?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1