Excel: copy cell with formula?

Discussion in 'AutoCAD' started by Ken Krupa, Jan 29, 2004.

  1. Ken Krupa

    Ken Krupa Guest

    When creating a new row, some cells want to use the same formula used in the
    cell in the first row. For instance if the formula in cell M2 is
    =J2-Config!$AC$2-Config!$AC$2 and I am creating row 9, then the formula for
    M9 should be =J9-Config!$AC$2-Config!$AC$2 (the references to cells on
    another sheet should not change).

    When copying the cell manually, this happens automatically. But I have not
    figured out how to so this programmatically. I can get the formula from M2
    and paste it into M9, but that copies the formula text verbatim. Is there a
    way to copy it and have it updated for the new cell?

    Also, could anyone recommend a good book that would cover this?

    Using 2004, with reference set to EXCEL9.OLB.

    Ken Krupa
     
    Ken Krupa, Jan 29, 2004
    #1
  2. Ken Krupa

    Ken Krupa Guest

    OK, no response here but I got it elsewhere. Here's what I needed, in case
    anyone else is interested:

    Set objSheet = objExcel.Worksheets("Flat Panels")
    With objExcel
    .Range("M2").Select
    .Selection.Copy 'copy contents of cell
    .Range("M9").PasteSpecial xlPasteFormulas 'paste as formula
    End With
     
    Ken Krupa, Jan 30, 2004
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.