I have a code to split the path name into separate columns. However it is not splitting it correctly.
The S/N column is from the path after Gantry1\
The year column should be 2021
The month column should be 01
the date column should be 08
However after running the macro, the year became 1 and the month became 8 and the date became 16
I would greatly appreciate your help to find out what is the problem with my code.
The S/N column is from the path after Gantry1\
The year column should be 2021
The month column should be 01
the date column should be 08
However after running the macro, the year became 1 and the month became 8 and the date became 16
I would greatly appreciate your help to find out what is the problem with my code.
VBA Code:
If InStr(DestinationRange, "Gantry1") > 0 Then
DestinationRange.Offset(0, 3) = Split(Split(DestinationRange.Value, "Gantry1\")(1), "\")(0) 'S/N
DestinationRange.Offset(0, 4) = Split(Split(DestinationRange.Value, "Gantry1\")(1), "_")(1) 'Year
DestinationRange.Offset(0, 5) = Split(Split(DestinationRange.Value, "Gantry1\")(1), "_")(2) 'Month
DestinationRange.Offset(0, 6) = Split(Split(DestinationRange.Value, "Gantry1\")(1), "_")(3) 'Day
yearonly = Split(Split(DestinationRange.Value, "Gantry1\")(1), "_")(1)
monthonly = Split(Split(DestinationRange.Value, "Gantry1\")(1), "_")(2)
dayonly = Split(Split(DestinationRange.Value, "Gantry1\")(1), "_")(3)
Dateonly = dayonly & "/" & monthonly & "/" & yearonly
DestinationRange.Offset(0, 7) = Dateonly
DestinationRange.Offset(0, 8) = WeekNum(Dateonly)