Need to press Enter before Excel recognizes Cell as a Date

Hermanie

Board Regular
Joined
Nov 28, 2016
Messages
56
Hi everyone,

I'm currently having a VBA coding which correctly reports the date in the desired format ("DD/MM/YYYY"). However, in the excel sheet, the value is not recognized as a date. Whenever I click the cell and hit enter, it then is immediately set as a date. The cell first is aligned to the left, after selecting the cell and pressing "Enter", it is aligned to the right. How can update the VBA coding such that I do not have to press enter in the cell? (I've tried TextToColumns as advised by other sites, which unfortunately did not work)

The VBA coding
ThisWorkbook.Sheets(1).Cells(29, 1) = Format(Now, "DD/MM/YYYY")
ThisWorkbook.Sheets(1).Cells(29, 1).NumberFormat = "DD/MM/YYYY"

Other settings
With Application
.DisplayAlerts = True
.ScreenUpdating = True
.EnableEvents = True
.DisplayStatusBar = True
.Calculation = xlCalculationAutomatic
.AskToUpdateLinks = True
End With
 

Attachments

  • Untitled.png
    Untitled.png
    1.9 KB · Views: 5

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
You are entering the date as text, try
VBA Code:
ThisWorkbook.Sheets(1).Cells(29, 1) = Date
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,853
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top