Results 1 to 2 of 2

Formula not copying correctly

Threaded View

  1. #1
    Registered User
    Join Date
    12-11-2012
    Location
    Columbia, South Carolina
    MS-Off Ver
    Excel 2007
    Posts
    4

    Formula not copying correctly

    I use this macro to insert rows into a ledger and it was working correctly, but for some reason, the formula on the last column is not copying down correctly when I run the macro. Here is the macro:

    Sub Insert_Rows()

    If Selection.Rows.Count <> 1 Then Exit Sub
    If Selection.Areas.Count <> 1 Then Exit Sub
    With Selection.EntireRow
    Selection.Locked = False
    .Offset(-1).Copy
    .Insert
    On Error Resume Next
    .Offset(-1).SpecialCells(xlCellTypeConstants, 23).ClearContents
    On Error GoTo 0
    End With

    End Sub

    Here is the formula:
    =IF(AND(ISBLANK(H83),ISBLANK(I83)),"",SUM(K82-H83+I83))

    When I select a cell in row 83 and run the macro, the formula in the newly inserted row should be this:
    =IF(AND(ISBLANK(H83),ISBLANK(I83)),"",SUM(K82-H83+I83))
    ----Which it is. The code inserts a blank row in the row that is selected. However, the formula in the new row 84 should be this:
    =IF(AND(ISBLANK(H84),ISBLANK(I84)),"",SUM(K83-H84+I84)); instead it is:
    =IF(AND(ISBLANK(H84),ISBLANK(I84)),"",SUM(K82-H84+I84))

    This code used to work, but for some reason today it is not. Any thoughts on what is happening? Locking or unlocking the cells that contain the formula has no effect.
    Last edited by dale040205; 12-11-2012 at 01:36 PM. Reason: grammar---grr

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