Results 1 to 1 of 1

Thread: How toSave Emails in Excel File With Date and Time?

  1. #1
    Junior Member
    Join Date
    Jan 2024
    Posts
    1
    Rep Power
    0

    How toSave Emails in Excel File With Date and Time?

    To save emails in an Excel file with the date and time using a formula, you can use the following steps:

    If you want to export Outlook emails to Excel with date and time, then first download the emails from your mailbox.

    1.Get Current Date and Time:

    Use the formula =NOW() to get the current date and time.

    2. Convert Date and Time to Text:

    To convert the dynamic date and time into a text string, use the formula =TEXT(NOW(), "YYYYMMDD_HHMMSS"). This will format the date and time as "YYYYMMDD_HHMMSS".

    3. Create a File Name:

    Concatenate the text string with a suitable file name using the CONCATENATE or & operator. For example, if you want to prefix the file name with "Emails_", you can use =CONCATENATE("Emails_", TEXT(NOW(), "YYYYMMDD_HHMMSS")) or "Emails_" & TEXT(NOW(), "YYYYMMDD_HHMMSS").

    4. Save as Excel File:

    Unfortunately, Excel formulas alone cannot save files directly. You can use VBA (Visual Basic for Applications) to automate saving the file.
    Here is an example of a VBA code that can be used in Excel to save the workbook with the dynamically generated file name:

    Sub SaveWorkbookWithDateAndTime()
    Dim fileName As String
    fileName = "Emails_" & Format(Now(), "YYYYMMDD_HHMMSS") & ".xlsx"
    ThisWorkbook.SaveAs fileName
    End Sub


    To use this code:

    • Press ALT + F11 to open the Visual Basic for Applications editor.
    • Insert a new module (Right-click on a project > Insert > Module).
    • Copy and paste the code into the module.
    • Close the editor and run the macro by pressing ALT + F8, selecting SaveWorkbookWithDateAndTime, and clicking Run.


    This VBA code will save the current workbook with the specified file name format including the date and time. Remember to enable macros in your Excel settings for this to work.
    Last edited by sandy666; 01-09-2024 at 01:18 PM.

Similar Threads

  1. Replies: 9
    Last Post: 08-14-2020, 12:28 PM
  2. Extract Time in 24H format from Date and time.
    By zorro in forum Excel Help
    Replies: 3
    Last Post: 09-01-2016, 07:20 PM
  3. Replies: 7
    Last Post: 08-25-2016, 04:14 PM
  4. Extract Time from a Date&time cell
    By Feebles in forum Excel Help
    Replies: 4
    Last Post: 11-09-2015, 06:24 AM
  5. Replies: 1
    Last Post: 06-28-2014, 11:31 AM

Posting Permissions

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