+ Reply to Thread
Results 1 to 2 of 2

help help help compile error

  1. #1
    ashw1984
    Guest

    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

  2. #2
    Bob Phillips
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1