ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   help help help compile error (https://www.excelbanter.com/excel-discussion-misc-queries/68180-help-help-help-compile-error.html)

ashw1984

help help help compile error
 
the section of this code that say's
(.Rows.count
give's a compile error
but it never used to
i don't think i have changed anything
please can anybody tell me why


Sub CalculateResults()
'this macro calculates the speeds and lengths of the vehicles

If IsEmpty(Range("A6").Value) Then
MsgBox "No Data"
Exit Sub
End If
'this is a fail safe to stop the macro if the sheet is empty

With ActiveSheet.Range("E6:E" & .Cells(.Rows.count,
"D").End(xlUp).Row).FormulaR1C1 _
= "=(R2C8/(RC[-3]-RC[-4]))*(3600/1609344)"
End With
'this code inputs a formula into every cell in column e that has a
coresponding value in row d
With ActiveSheet.Range("f6:f" & .Cells(.Rows.count,
"D").End(xlUp).Row).FormulaR1C1 _
= "=(R2C8/(RC[-2]-RC[-3]))*(3600/1609344)"
End With
'as above but for column f
With ActiveSheet.Range("g6:g" & .Cells(.Rows.count,
"D").End(xlUp).Row).FormulaR1C1 _
= "=average(rc[-1]:rc[-2])"
End With
'as above but for column g
With ActiveSheet.Range("h6:h" & .Cells(.Rows.count,
"D").End(xlUp).Row).FormulaR1C1 _
= "=((rc[-1]/(3600/1609344))*(((rc[-5]-rc[-7])+(rc[-4]-rc[-6]))/2))/1000"
End With
'as above but for column h

End Sub

Bob Phillips

help help help compile error
 
Try this

With ActiveSheet
.Range("E6:E" & .Cells(.Rows.count, "D").End(xlUp).Row).FormulaR1C1 _
= "=(R2C8/(RC[-3]-RC[-4]))*(3600/1609344)"
End With


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"ashw1984" wrote in message
...
the section of this code that say's
(.Rows.count
give's a compile error
but it never used to
i don't think i have changed anything
please can anybody tell me why


Sub CalculateResults()
'this macro calculates the speeds and lengths of the vehicles

If IsEmpty(Range("A6").Value) Then
MsgBox "No Data"
Exit Sub
End If
'this is a fail safe to stop the macro if the sheet is empty

With ActiveSheet.Range("E6:E" & .Cells(.Rows.count,
"D").End(xlUp).Row).FormulaR1C1 _
= "=(R2C8/(RC[-3]-RC[-4]))*(3600/1609344)"
End With
'this code inputs a formula into every cell in column e that has a
coresponding value in row d
With ActiveSheet.Range("f6:f" & .Cells(.Rows.count,
"D").End(xlUp).Row).FormulaR1C1 _
= "=(R2C8/(RC[-2]-RC[-3]))*(3600/1609344)"
End With
'as above but for column f
With ActiveSheet.Range("g6:g" & .Cells(.Rows.count,
"D").End(xlUp).Row).FormulaR1C1 _
= "=average(rc[-1]:rc[-2])"
End With
'as above but for column g
With ActiveSheet.Range("h6:h" & .Cells(.Rows.count,
"D").End(xlUp).Row).FormulaR1C1 _
= "=((rc[-1]/(3600/1609344))*(((rc[-5]-rc[-7])+(rc[-4]-rc[-6]))/2))/1000"
End With
'as above but for column h

End Sub





All times are GMT +1. The time now is 04:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com