PDA

View Full Version : How toSave Emails in Excel File With Date and Time?



alora
01-09-2024, 12:56 PM
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 (https://no links to paid software), 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.