W
Wonderer
I have created a basic check book ledger and I use a macro to add a row when
I need more space. It adds the row ok, but it does not add the equation from
the "balance" column to the balance cell in the new row. How do I accomplish
that? Here is an example of the equations. I add the row to the top, so that
my most recent balance is seen upon opening the sheet.
=IF(AND(ISBLANK(E4),ISBLANK(G4)),"",H5+E4-G4)
=IF(AND(ISBLANK(E5),ISBLANK(G5)),"",H6+E5-G5)
=IF(AND(ISBLANK(E6),ISBLANK(G6)),"",H7+E6-G6)
=IF(AND(ISBLANK(E7),ISBLANK(G7)),"",H8+E7-G7)
The code that I use to add the row is as follows. What do I need to the
code, to get it to add in the equation as well?
Sub Insert_Row()
'sets the password
Const Password = "check" '**Change password here**
'unprotectes the sheet
Sheet1.Unprotect Password:=Password
'inserts the row
Rows("3:3").Insert Shift:=xlDown, _
CopyOrigin:=xlFormatFromRightOrBelow
'selects cell B3
[B3].Select
'protectes the sheet
Sheet1.Protect Password:=Password
Sheet1.EnableSelection = xlUnlockedCells
End Sub
--
Steven Shelton
There are two secrets to success in life
1) Never tell anybody everything you know
I need more space. It adds the row ok, but it does not add the equation from
the "balance" column to the balance cell in the new row. How do I accomplish
that? Here is an example of the equations. I add the row to the top, so that
my most recent balance is seen upon opening the sheet.
=IF(AND(ISBLANK(E4),ISBLANK(G4)),"",H5+E4-G4)
=IF(AND(ISBLANK(E5),ISBLANK(G5)),"",H6+E5-G5)
=IF(AND(ISBLANK(E6),ISBLANK(G6)),"",H7+E6-G6)
=IF(AND(ISBLANK(E7),ISBLANK(G7)),"",H8+E7-G7)
The code that I use to add the row is as follows. What do I need to the
code, to get it to add in the equation as well?
Sub Insert_Row()
'sets the password
Const Password = "check" '**Change password here**
'unprotectes the sheet
Sheet1.Unprotect Password:=Password
'inserts the row
Rows("3:3").Insert Shift:=xlDown, _
CopyOrigin:=xlFormatFromRightOrBelow
'selects cell B3
[B3].Select
'protectes the sheet
Sheet1.Protect Password:=Password
Sheet1.EnableSelection = xlUnlockedCells
End Sub
--
Steven Shelton
There are two secrets to success in life
1) Never tell anybody everything you know