Hi Folks,
I am running a code that I use everyday without fault , nothing has changed but I am getting a run time error which has dwindle my motivation to fix it.
here is the vba script with the error highlighted.
Public Sub ROCSORT()
TotalRowsROC = Worksheets("ROC").UsedRange.Rows.Count
Worksheets("ROC").Cells(1, 4) = "FDATE"
For RROC = 2 To TotalRowsROC
DateROC = Worksheets("ROC").Cells(RROC, 1)
DayROC = Mid(DateROC, 1, 2)
MonthROC = Mid(DateROC, 3, 3)
YEARROC = Mid(DateROC, 6, 2)
DayROC = Val(DayROC)
YEARROC = Val(YEARROC)
If MonthROC = "JAN" Then
MonthROC = 1
ElseIf MonthROC = "FEB" Then
MonthROC = 2
ElseIf MonthROC = "MAR" Then
MonthROC = 3
ElseIf MonthROC = "APR" Then
MonthROC = 4
ElseIf MonthROC = "MAY" Then
MonthROC = 5
ElseIf MonthROC = "JUN" Then
MonthROC = 6
ElseIf MonthROC = "JUL" Then
MonthROC = 7
ElseIf MonthROC = "AUG" Then
MonthROC = 8
ElseIf MonthROC = "SEP" Then
MonthROC = 9
ElseIf MonthROC = "OCT" Then
MonthROC = 10
ElseIf MonthROC = "NOV" Then
MonthROC = 11
ElseIf MonthROC = "DEC" Then
MonthROC = 12
End If
ROCFDATE = DayROC & "/" & MonthROC & "/" & YEARROC
ROCFDATE = CDate(ROCFDATE) (error)
Worksheets("ROC").Cells(RROC, 4) = ROCFDATE
Next RROC
Worksheets("ROC").UsedRange.Sort _
Key1:=Worksheets("ROC").Columns(4), _
Key2:=Worksheets("ROC").Columns(8), _
Order1:=xlDescending, _
Header:=xlYes
End Sub
Can someone please help me ?
I am running a code that I use everyday without fault , nothing has changed but I am getting a run time error which has dwindle my motivation to fix it.
here is the vba script with the error highlighted.
Public Sub ROCSORT()
TotalRowsROC = Worksheets("ROC").UsedRange.Rows.Count
Worksheets("ROC").Cells(1, 4) = "FDATE"
For RROC = 2 To TotalRowsROC
DateROC = Worksheets("ROC").Cells(RROC, 1)
DayROC = Mid(DateROC, 1, 2)
MonthROC = Mid(DateROC, 3, 3)
YEARROC = Mid(DateROC, 6, 2)
DayROC = Val(DayROC)
YEARROC = Val(YEARROC)
If MonthROC = "JAN" Then
MonthROC = 1
ElseIf MonthROC = "FEB" Then
MonthROC = 2
ElseIf MonthROC = "MAR" Then
MonthROC = 3
ElseIf MonthROC = "APR" Then
MonthROC = 4
ElseIf MonthROC = "MAY" Then
MonthROC = 5
ElseIf MonthROC = "JUN" Then
MonthROC = 6
ElseIf MonthROC = "JUL" Then
MonthROC = 7
ElseIf MonthROC = "AUG" Then
MonthROC = 8
ElseIf MonthROC = "SEP" Then
MonthROC = 9
ElseIf MonthROC = "OCT" Then
MonthROC = 10
ElseIf MonthROC = "NOV" Then
MonthROC = 11
ElseIf MonthROC = "DEC" Then
MonthROC = 12
End If
ROCFDATE = DayROC & "/" & MonthROC & "/" & YEARROC
ROCFDATE = CDate(ROCFDATE) (error)
Worksheets("ROC").Cells(RROC, 4) = ROCFDATE
Next RROC
Worksheets("ROC").UsedRange.Sort _
Key1:=Worksheets("ROC").Columns(4), _
Key2:=Worksheets("ROC").Columns(8), _
Order1:=xlDescending, _
Header:=xlYes
End Sub
Can someone please help me ?