Hello All
I have below attachment
when I enter a text in cell H automatically the today date appears (by vba code) on Cell E Full Day format
Cell D Year Format
Cell C Month Format
Cell B Day Format
but when I put the mouse curser on D,C & B format i see full day on formula bar
Is there a solution to see only year on formula bar for cell D
&
to see only month on formula bar for cell C
&
to see only day on formula bar for cell D
The below code is change the date format but what I need exactly is to extract part of the date either year, month or day
Private Sub Worksheet_Change(ByVal Target As Range)
'today date if cell is not blank
Dim rInt As Range
Dim rCell As Range
Dim tCell As Range
Set rInt = Intersect(Target, Range("H:H"))
If Not rInt Is Nothing Then
For Each rCell In rInt
Set tCell = rCell.Offset(0, -3)
If IsEmpty(tCell) Then
tCell = Date
tCell.NumberFormat = "dd.mm.yyyy"
End If
Next
End If
'divide date to year,month,days
If Target.Count > 1 Then Exit Sub
If Target.Column <> 5 Then Exit Sub
If Target <> "" And IsDate(Target) Then
Target.Offset(, -3).Resize(, 3) = Target
Target.Offset(, -3).NumberFormat = "dd"
Target.Offset(, -2).NumberFormat = "mmm"
Target.Offset(, -1).NumberFormat = "yyyy"
Else
Target.Offset(, -3).Resize(, 3) = ""
End If
End Sub
Thank you
Attachment 453146
Bookmarks