Hi there, I have the following VBA code which is running great in excel 2010, however when I am trying to ru the same vba in excel 2007 it pops up with Run time error 13 with the following row (highlighted in red and bold) becomes an issue.
Can anyone please help?
Range("F264").Select
For x = 1 To 10000
RW = ActiveCell.Row
'ActiveCell.Offset(1, 0).Select
'Get Position, Check for Date in the field, collect the values:
'SD - Startdate, ED = End date, Mths = Months, Cost = Cost
If ActiveCell.Row > 496 Then GoTo 200
If IsDate(ActiveCell.Value) = True Then Else GoTo 100
SD = ActiveCell.Offset(0, -1).Value
ED = ActiveCell.Offset.Value
Mths = ActiveCell.Offset(0, 1).Value
COST = ActiveCell.Offset(0, 2).Value
Scol = ActiveCell.Column
'Position in the data range, and build the calculation based on dates
'Firstly find the start:
ActiveCell.Offset(0, 8).Activate
For Y = 8 To 100
If ActiveCell.Offset(-(RW - 260), 0).Value = ActiveCell.Offset(0, -Y).Value Then GoTo 50
ActiveCell.Offset(0, 1).Select
Next Y
Cells(RW, 6).Select
GoTo 100
50:
'Use the HLookup to set the values
Ecol = ActiveCell.Column
'Y = Y - 2
ActiveCell.Offset(0, 2).Select
For Z = 20 To (20 - Mths) + 1 Step -1
ActiveCell.FormulaR1C1 = "=HLOOKUP(" & Z & ",R253C14:R255C33,2)*" & COST & "+ 1000*HLOOKUP(" & Z & ",R253C14:R256C33,3)"
ActiveCell.Offset(0, -1).Select
If ActiveCell.Column = 13 Then GoTo 100
Next Z
100:
Cells(RW + 1, 6).Select
Next x
Bookmarks