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 ?
 

Some videos you may like

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,230
Office Version
  1. 365
Platform
  1. Windows
What's the value of DateROC when you get the error?
 

Watch MrExcel Video

Forum statistics

Threads
1,123,259
Messages
5,600,572
Members
414,389
Latest member
MarkElla

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
Top