+ Reply to Thread
Results 1 to 3 of 3

Copying formula to the bottom of a range

  1. #1
    jeremy nickels
    Guest

    Copying formula to the bottom of a range

    I'm trying to create a macro that copies a formula in a column down to the
    bottom of a range.

    For example, I have data in columns A - L. In column M, I want to create a
    formula and copy it down to the bottom of my data. The only problem is my
    data is dynamic. One day it might end on row 1038, another day it might end
    on row 1152.

    Anyone have VBA code that can help me do this?

  2. #2
    Tom Ogilvy
    Guest

    Re: Copying formula to the bottom of a range

    set rng = range(cells(1,"L"),cells(rows.count,"L").End(xlup))
    rng.offset(0,1).Formula = "=Sum(A1:C1)"

    make the formula relative to the first cell in your range and use absolute
    and relative addressing as appropriate.

    if you already have it in M1 for example, then it would be
    set rng = range(cells(1,"L"),cells(rows.count,"L").End(xlup))
    rng.offset(0,1).Formula = Range("M1").formula

    --
    Regards,
    Tom Ogilvy



    "jeremy nickels" <jeremy [email protected]> wrote in message
    news:[email protected]...
    > I'm trying to create a macro that copies a formula in a column down to the
    > bottom of a range.
    >
    > For example, I have data in columns A - L. In column M, I want to create

    a
    > formula and copy it down to the bottom of my data. The only problem is my
    > data is dynamic. One day it might end on row 1038, another day it might

    end
    > on row 1152.
    >
    > Anyone have VBA code that can help me do this?




  3. #3
    jeremy nickels
    Guest

    Re: Copying formula to the bottom of a range

    thanks Tom, that worked like a charm.

    "Tom Ogilvy" wrote:

    > set rng = range(cells(1,"L"),cells(rows.count,"L").End(xlup))
    > rng.offset(0,1).Formula = "=Sum(A1:C1)"
    >
    > make the formula relative to the first cell in your range and use absolute
    > and relative addressing as appropriate.
    >
    > if you already have it in M1 for example, then it would be
    > set rng = range(cells(1,"L"),cells(rows.count,"L").End(xlup))
    > rng.offset(0,1).Formula = Range("M1").formula
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    >
    > "jeremy nickels" <jeremy [email protected]> wrote in message
    > news:[email protected]...
    > > I'm trying to create a macro that copies a formula in a column down to the
    > > bottom of a range.
    > >
    > > For example, I have data in columns A - L. In column M, I want to create

    > a
    > > formula and copy it down to the bottom of my data. The only problem is my
    > > data is dynamic. One day it might end on row 1038, another day it might

    > end
    > > on row 1152.
    > >
    > > Anyone have VBA code that can help me do this?

    >
    >
    >


+ 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