Run time error

movingon2

New Member
Joined
Jun 30, 2015
Messages
2
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 ?
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
What's the value of DateROC when you get the error?
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top