+ Reply to Thread
Results 1 to 2 of 2

auto sort by date event macro

  1. #1
    Registered User
    Join Date
    03-10-2008
    Posts
    10

    auto sort by date event macro

    Hello all and thank you for looking,

    I have a program that automatically feeds a set of values into excel. The outside program can only feed into one row, say row 5000, and puts a date and time stamp in column C.

    I was wondering when excel is opened by this outside program an event macro can be used to auto sort the previously entered data? If the previously entered data is not manually moved or sorted before the outside program opens excel and enters new data, the previous data is overwritten and lost.

    Is it possible to sort by the date/time stamp sequentially so that when the program opens the previously entered data will move to say, row 1? Then the next batch of data will be entered and excel would close. When the program opens excel the next time, the data that was input into row 5000 on the last run will move to row 2, input the new data and close again. etc etc.

    Like this

    Outside Program opens Excel
    Excel Sorts data by date time stamp(oldest in row 1)
    Outside program enters new data into row 5000 and closes excel.

    Outside Program opens excel
    Excel Sorts data by date/time(oldest in row 1, 2nd oldest in row 2 etc)
    Outside program enters new data into row 5000 and closes excel.


    The oldest data needs to be first in the column.

    IF anyone has any insight on this, it would be greatly appreciated

    Mike

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Mike,

    Change the worksheet name and column in the macro below before you install it. The changes you need to make are in blue.
    Please Login or Register  to view this content.
    How to Save a Workbook Event Macro
    1. Copy the macro using CTRL+C keys.
    2. Open your Workbook and Right Click on any Worksheet's Name Tab
    3. Left Click on View Code in the pop up menu.
    4. Press ALT+F11 keys to open the Visual Basic Editor.
    5. Press CTRL+R keys to shift the focus to the Project Explorer Window
    6. Press the Down Arrow Key until ThisWorkbook is highlighted in blue.
    7. Press the Enter key to move the cursor to the Code Window
    8. Paste the macro code using CTRL+V
    9. Save the macro in your Workbook using CTRL+S

    Sincerely,
    Leith Ross
    Last edited by Leith Ross; 03-13-2008 at 01:07 PM.

+ 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