R
russell-skmr3
Hi Everyone.
I have some code to change a month reference in a file
path variable. If possible could someone help me in
simplifying this code? Any help would be greatly
appreciated.
---code----
Sub ChangeDateInFilePath()
strcmonth = Range("A7").Value ' H:\Temp\Jul03\
strb1month = Left(strcmonth, 8) ' -> H:\Temp\
strb2month = Right(strcmonth, 3) ' -> 03\
strw1month = Right(strcmonth, 6) ' -> Jul03\
strw2month = Left(strw1month, 3) ' -> Jul
If strw2month = "Jan" Then
strw3month = "Feb"
ElseIf strw2month = "Feb" Then
strw3month = "Mar"
ElseIf strw2month = "Mar" Then
strw3month = "Apr"
ElseIf strw2month = "Apr" Then
strw3month = "May"
ElseIf strw2month = "May" Then
strw3month = "Jun"
ElseIf strw2month = "Jun" Then
strw3month = "Jul"
ElseIf strw2month = "Jul" Then
strw3month = "Aug"
ElseIf strw2month = "Aug" Then
strw3month = "Sep"
ElseIf strw2month = "Sep" Then
strw3month = "Oct"
ElseIf strw2month = "Oct" Then
strw3month = "Nov"
ElseIf strw2month = "Nov" Then
strw3month = "Dec"
ElseIf strw2month = "Dec" Then
strw3month = "Jan"
End If
strnewmonth = strb1month & strw3month & strb2month
Range("A9").Value = strnewmonth
End Sub
I have some code to change a month reference in a file
path variable. If possible could someone help me in
simplifying this code? Any help would be greatly
appreciated.
---code----
Sub ChangeDateInFilePath()
strcmonth = Range("A7").Value ' H:\Temp\Jul03\
strb1month = Left(strcmonth, 8) ' -> H:\Temp\
strb2month = Right(strcmonth, 3) ' -> 03\
strw1month = Right(strcmonth, 6) ' -> Jul03\
strw2month = Left(strw1month, 3) ' -> Jul
If strw2month = "Jan" Then
strw3month = "Feb"
ElseIf strw2month = "Feb" Then
strw3month = "Mar"
ElseIf strw2month = "Mar" Then
strw3month = "Apr"
ElseIf strw2month = "Apr" Then
strw3month = "May"
ElseIf strw2month = "May" Then
strw3month = "Jun"
ElseIf strw2month = "Jun" Then
strw3month = "Jul"
ElseIf strw2month = "Jul" Then
strw3month = "Aug"
ElseIf strw2month = "Aug" Then
strw3month = "Sep"
ElseIf strw2month = "Sep" Then
strw3month = "Oct"
ElseIf strw2month = "Oct" Then
strw3month = "Nov"
ElseIf strw2month = "Nov" Then
strw3month = "Dec"
ElseIf strw2month = "Dec" Then
strw3month = "Jan"
End If
strnewmonth = strb1month & strw3month & strb2month
Range("A9").Value = strnewmonth
End Sub