Formula goes awry when deleting row, #REF! error

Kusaywa

Board Regular
Joined
Aug 26, 2016
Messages
123
I enter info into my spreadsheet using a form which moves the top row down and inserts new data.
My formula works fine, continuing up the sheet.
If I delete any row other than the top row, my formula goes awry giving me a #REF! error up the column.
How do I delete a row without screwing up the formula?
Here's my formula: =IF(ISBLANK(C5),"",SUM(G6-E5+F5))
And here is the code for inserting a new row.
Thanks for any help

VBA Code:
Private Sub Submit_Click()
Dim n As Long
With Sheets("Checkbook Register")

    .Rows("5:5").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromRightOrBelow
    n = 5
    
    .Cells(n, "B") = [Text(Now(), "MM-DD-YYYY")]
    .Cells(n, "C") = TextBox1.Value
    .Cells(n, "D") = TextBox2.Value
    .Cells(n, "E") = TextBox3.Value
    .Cells(n, "F") = TextBox4.Value
    
End With
Unload Me
End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
You can try this formula

Excel Formula:
=IF(ISBLANK(C5),"",SUM(OFFSET(G5,1,0)-OFFSET(E5,1,0)+OFFSET(F5,1,0)))
 
Upvote 0
=IF(ISBLANK(C5),"",SUM(OFFSET(G5,1,0)-OFFSET(E5,1,0)+OFFSET(F5,1,0)))
This subtracts the amount in E6 for some reason. If I change G5 to G6 (where either E5 or F5 either adds or subtracts from G6) the total stays the same. Remember, I am totaling up and not down column G.
Additionally, there really is no reason for =IF(ISBLANK(C5),"", as there should never not be a transaction entry.
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top