Consulting

Results 1 to 2 of 2

Thread: copy down formula

  1. #1
    VBAX Contributor
    Joined
    Apr 2008
    Posts
    136
    Location

    copy down formula

    Good morning!

    I am using this piece of code to copy a formula down. I am using column A as base for how many rows to copy down to. Adjacent column is not always populated fully.

    It copies down ok however copies down one extra row.
    I deleted this row to make sure its not reading a space or anything, but still happening. Is there more of an efficient way of writing this?

    [VBA] LRw = Cells(Rows.Count, "A").End(xlUp).Row - 1
    ActiveCell.Resize(LRw - 1).FormulaR1C1 = "=IF(RC[-2]=0,""-"",(RC[-1]/RC[-2]))" [/VBA]

    Can anyone have a quick look. Much appreciated.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Maybe this?

    [vba]

    With ActiveCell

    LRw = Cells(Rows.Count, "A").End(xlUp).Row - .Row + 1
    .Resize(LRw).FormulaR1C1 = "=IF(RC[-2]=0,""-"",(RC[-1]/RC[-2]))"
    End With
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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