Здравствуйте, уважаемые форумчане! Суть макроса состоит в преобразовании даты, введённой в ячейку как текст в формате, напр. 02-Apr-12 в формат 02.04.2012. Думаю, есть более короткий вариант решения макросом. Спасибо, кто предложит более рациональное решение.
Sub ConvertData ()
Dim MonthN As Integer
Dim Day As String, Month As String, Year As String
Dim Data As Date
' Cells(1, 1) = "02-Apr-12"
Day = Left(Cells(1, 1), 2)
Month = Mid(Cells(1, 1), 4, 3)
If Month = "Jan" Then MonthN = 1
If Month = "Feb" Then MonthN = 2
If Month = "Mar" Then MonthN = 3
If Month = "Apr" Then MonthN = 4
If Month = "May" Then MonthN = 5
If Month = "Jun" Then MonthN = 6
If Month = "Jul" Then MonthN = 7
If Month = "Aug" Then MonthN = 8
If Month = "Sep" Then MonthN = 9
If Month = "Okt" Then MonthN = 10
If Month = "Nov" Then MonthN = 11
If Month = "Dec" Then MonthN = 12
Year = "20" & Right(Cells(1, 1), 2)
Data = DateSerial(Year, MonthN, Day)
Cells(1, 2).Value = Data
End Sub
Sub ConvertData ()
Dim MonthN As Integer
Dim Day As String, Month As String, Year As String
Dim Data As Date
' Cells(1, 1) = "02-Apr-12"
Day = Left(Cells(1, 1), 2)
Month = Mid(Cells(1, 1), 4, 3)
If Month = "Jan" Then MonthN = 1
If Month = "Feb" Then MonthN = 2
If Month = "Mar" Then MonthN = 3
If Month = "Apr" Then MonthN = 4
If Month = "May" Then MonthN = 5
If Month = "Jun" Then MonthN = 6
If Month = "Jul" Then MonthN = 7
If Month = "Aug" Then MonthN = 8
If Month = "Sep" Then MonthN = 9
If Month = "Okt" Then MonthN = 10
If Month = "Nov" Then MonthN = 11
If Month = "Dec" Then MonthN = 12
Year = "20" & Right(Cells(1, 1), 2)
Data = DateSerial(Year, MonthN, Day)
Cells(1, 2).Value = Data
End Sub