Jump to content

How to automatically enter dates in Excel? - (Moved)


Recommended Posts

I'm using excel to complete my report, but I'm having a bit of trouble that I don't know how to auto-generate the date, so I have to enter it completely manually, so as not to get confused. So it took me quite a while to enter the information. Is there any way to solve this problem? Please guide me

Link to post
Share on other sites
  • Developers

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

Something like this? This little example writes the current date to cell A1 aon Sheet 1:

#include <Excel.au3>
Global $oExcel = _Excel_Open()
Global $oWorkbook = _Excel_BookNew($oExcel)
_Excel_RangeWrite($oWorkbook, 1, "=TODAY()", "A1", False)

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (NEW 2021-06-14 - Version 1.6.5.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (NEW 2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

With the $bValue parameter as true (all credits for water and Chimp)

#include <Date.au3>

#include <Excel.au3>
Global $oExcel = _Excel_Open()
Global $oWorkbook = _Excel_BookNew($oExcel)
Global $oSheet = $oWorkbook.ActiveSheet
$oSheet.Range("A1").NumberFormat = "dd/mm;@"

;Chimp, May 09, 2016
;https://www.autoitscript.com/forum/topic/182401-problem-with-date-calculation/?do=findComment&comment=1309969
;https://www.autoitscript.com/wiki/Excel_UDF#Date_and_Time
;http://www.cpearson.com/excel/datetime.htm
_Excel_RangeWrite($oWorkbook, 1, _DateDiff('D',  "1900/01/01", _NowCalcDate()) + 2, "A1", True)

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...