GirishDhruva
Active Member
- Joined
- Mar 26, 2019
- Messages
- 308
Hi Everyone,
Here i am trying to convert multiple columns from numbers to date(Columns are M,N,O)
I tried for converting only one column, but couldn't do the same for multiple columns in one Loop.
Can anyone suggest me how i can do this.......
Thanks in advance
Here i am trying to convert multiple columns from numbers to date(Columns are M,N,O)
I tried for converting only one column, but couldn't do the same for multiple columns in one Loop.
Can anyone suggest me how i can do this.......
Code:
row = 2
Do While Cells(row, 11).Value <> ""
mydate = CStr(Cells(row, 13))
If Len(mydate) = 7 Then
myday = Left(mydate, 1)
mymonth = Mid(mydate, 2, 2)
myyear = Right(mydate, 4)
Cells(row, 13).NumberFormat = "dd/mm/yyyy"
Cells(row, 13).Value = CDate(myday & "-" & mymonth & "-" & myyear)
ElseIf Len(mydate) = 8 Then
myday = Left(mydate, 2)
mymonth = Mid(mydate, 3, 2)
myyear = Right(mydate, 4)
Cells(row, 13).NumberFormat = "dd/mm/yyyy"
Cells(row, 13).Value = CDate(myday & "-" & mymonth & "-" & myyear)
End If
row = row + 1
Loop