+ Reply to Thread
Results 1 to 2 of 2

Copy formulas via Code

  1. #1
    Cordobes
    Guest

    Copy formulas via Code

    I have a range with formulas on sheet2 called "database". I want to get this
    range and transfer it's contents to sheet1 called "work", but I want the
    formulas to update themselves to this new location, and not show the same
    exact formula that was found in the original range. I had tried :

    sheets("work").range("a1:b10").formula =
    sheets("database").range("d1:e10").formula

    with the following results

    Cells d1 to d10 on sheet database contain X values, and cells e1 to e10
    contain the formula =d1*d1, =d2*d2, and so forth.

    What I obtain on cells a1 to b10 on sheet work is exactly the same formulase
    outlined above ( ie : = d1*d2 ) instead of the formula getting updated to =
    a1*a1, = a2*a2.

    I don't want to use the copy paste method because it changes the sheet
    selection and I have code written for the activate and deactivate events on
    each of these sheets.

    Any suggestions?

  2. #2
    Dave Peterson
    Guest

    Re: Copy formulas via Code

    One way:

    Sheets("work").Range("a1:b10").FormulaR1C1 _
    = Sheets("database").Range("d1:e10").FormulaR1C1

    Another way is to copy|paste special|formulas



    Cordobes wrote:
    >
    > I have a range with formulas on sheet2 called "database". I want to get this
    > range and transfer it's contents to sheet1 called "work", but I want the
    > formulas to update themselves to this new location, and not show the same
    > exact formula that was found in the original range. I had tried :
    >
    > sheets("work").range("a1:b10").formula =
    > sheets("database").range("d1:e10").formula
    >
    > with the following results
    >
    > Cells d1 to d10 on sheet database contain X values, and cells e1 to e10
    > contain the formula =d1*d1, =d2*d2, and so forth.
    >
    > What I obtain on cells a1 to b10 on sheet work is exactly the same formulase
    > outlined above ( ie : = d1*d2 ) instead of the formula getting updated to =
    > a1*a1, = a2*a2.
    >
    > I don't want to use the copy paste method because it changes the sheet
    > selection and I have code written for the activate and deactivate events on
    > each of these sheets.
    >
    > Any suggestions?


    --

    Dave Peterson

+ 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