Use TextToColumns to quickly strip off the trailing characters and convert to dates.
With the text-that-look-like-dates in a fixed dd.mm.yyyy format,
with selection
.TextToColumns Destination:=.cells(1, 1), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, xlDMYFormat), Array(10, xlSkipColumn))
.numberformat = "dd.mm.yyyy"
end with
With the text-that-look-like-dates showing a space after the date and before the trailing text,
With Selection
.TextToColumns Destination:=.Cells(1, 1), DataType:=xlDelimited, ConsecutiveDelimiter:=True, _
Tab:=False, Semicolon:=False, Comma:=False, Space:=True, Other:=False, _
FieldInfo:=Array(Array(1, xlDMYFormat), Array(2, xlSkipColumn))
End With
If the TextToColumns is giving you problems with the Bulgarian month names (VBA is very US-EN-centric), then simply add a single line to your existing code and optionally set the cell format.
with Selection
.Replace What:=" г.", Replacement:=vbNullString, LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
.value = .value2
.numberformat = "dd.mm.yyyy"
end with
I've used Selection
here (not particularly recommended) but you should be able to easily convert.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…