I have a macro:
To solve this problem, I use this macro:
I have dates as MonthYear, Month-Year (May20, May-21, etc.) but I need them to be in dd.mm.yyyy format.
For example:
Aug20, needs to become 01.08.2020.
May-19, needs to become 01.05.2019.
Jul18, needs to become 01.07.2018.
Nov-17, needs to become 01.11.2017.
etc.
If you try to enter something other than the MonthYear, Month-Year type into the cells of column A, then nothing is entered into the cells, they should remain empty.
You can try setting your computer's regional settings to dd.mm.yyyy. Then set the format for all cells in column A (Cell format → Date → default should be dd.mm.yyyy). Insert my macro into an Excel sheet. Try doing the following with my macro: Copy from any cell (CTRL+C) the word «may20» and paste (CTRL+V) into any cell in column A. You will only be able to paste once.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As range)
Dim v, cell
Set Target = Application.Intersect(Target, Me.Columns(1), Me.UsedRange)
If Target Is Nothing Then Exit Sub
For Each cell In Target.Cells
v = cell.Value
If VarType(v) <> vbDate Then
Application.EnableEvents = False
If v Like "???##" Or v Like "???-##" Then cell.Value = Left(v, Len(v) - 2) & "20" & Right(v, 2)
If VarType(cell.Value) <> vbDate Then cell.Value = Empty
cell.NumberFormat = "dd/mm/yyyy"
With Target
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
Application.EnableEvents = True
End If
Next cell
End Sub
To solve this problem, I use this macro:
I have dates as MonthYear, Month-Year (May20, May-21, etc.) but I need them to be in dd.mm.yyyy format.
For example:
Aug20, needs to become 01.08.2020.
May-19, needs to become 01.05.2019.
Jul18, needs to become 01.07.2018.
Nov-17, needs to become 01.11.2017.
etc.
If you try to enter something other than the MonthYear, Month-Year type into the cells of column A, then nothing is entered into the cells, they should remain empty.
You can try setting your computer's regional settings to dd.mm.yyyy. Then set the format for all cells in column A (Cell format → Date → default should be dd.mm.yyyy). Insert my macro into an Excel sheet. Try doing the following with my macro: Copy from any cell (CTRL+C) the word «may20» and paste (CTRL+V) into any cell in column A. You will only be able to paste once.