Hello
Trying to enter Date as .NumberFormat = "dd/mm/yyyy;@" but result displays as "dd-mm-yyyy" Dont understand why
below for the reference
NimishK
Trying to enter Date as .NumberFormat = "dd/mm/yyyy;@" but result displays as "dd-mm-yyyy" Dont understand why
below for the reference
Code:
[COLOR=#ff0000][I]Code in thisWorkbook[/I][/COLOR]
Option Explicit
Private Sub Workbook_Open()
Dim ws As Worksheet
Set ws = Worksheets("Sheet2")
ws.Range("A:A").NumberFormat = "dd/mm/yyyy;@"
End Sub
[COLOR=#ff0000][I]code in sheet2[/I][/COLOR]
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ws As Worksheet
Set ws = Worksheets("Sheet2")
Dim dDate As Date
Dim thisRow As Long
If Target.Column = 1 Then
thisRow = Target.Row
If Not Target.Range("A" & thisRow).NumberFormat = "dd/mm/yyyy;@" Then
MsgBox "No Correct date"
Else
On Local Error GoTo errMsg:
dDate = Format(ws.Cells(thisRow, 1).Text, "dd/mm/yyyy;@")
Range("B" & thisRow).Value = dDate
errMsg:
MsgBox "Pl Enter Date in dd/mm/yyyy format "
Exit Sub
End If
End If
End Sub
Last edited: