Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default copy equation to new row

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default copy equation to new row

It appears that column H has the balance formula - correct? Assuming that is
so, then put this line of code someplace after you insert the new line:
Range(H3).Formula = "=IF(AND(ISBLANK(E3),ISBLANK(G3)),"",H4+E3-G3)

--
- K Dales


"Wonderer" wrote:

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default copy equation to new row

I do not understand what you mean by "put this line of code someplace after
you insert the new line" Please explain or give an example.

--

Steven Shelton

There are two secrets to success in life
1) Never tell anybody everything you know
"K Dales" wrote in message
...
It appears that column H has the balance formula - correct? Assuming that
is
so, then put this line of code someplace after you insert the new line:
Range(H3).Formula = "=IF(AND(ISBLANK(E3),ISBLANK(G3)),"",H4+E3-G3)

--
- K Dales


"Wonderer" wrote:

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





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default copy equation to new row

Sorry if not clear: it really doesn't matter where it goes as long as it is
after this:

'inserts the row
Rows("3:3").Insert Shift:=xlDown, _
CopyOrigin:=xlFormatFromRightOrBelow

So right after that you could put:

' copies the formula:
Range(H3).Formula = "=IF(AND(ISBLANK(E3),ISBLANK(G3)),"",H4+E3-G3)"
--
- K Dales


"Wonderer" wrote:

I do not understand what you mean by "put this line of code someplace after
you insert the new line" Please explain or give an example.

--

Steven Shelton

There are two secrets to success in life
1) Never tell anybody everything you know
"K Dales" wrote in message
...
It appears that column H has the balance formula - correct? Assuming that
is
so, then put this line of code someplace after you insert the new line:
Range(H3).Formula = "=IF(AND(ISBLANK(E3),ISBLANK(G3)),"",H4+E3-G3)

--
- K Dales


"Wonderer" wrote:

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






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default copy equation to new row

Yes, Mike is right - very sloppy on my part, sorry!
--
- K Dales


"Mike Fogleman" wrote:


Range("H3") , notice the Quotes.

Range("H3").Formula = "=IF(AND(ISBLANK(E3),ISBLANK(G3)),"",H4+E3-G3)"

Mike F

" Wonderer" wrote in message
...
Part of the problem was that it was not saving the code, for some reason.
I got it to save and tried it again and the following error occured

run-time error '1004':
Method 'range' of object '_Global' failed

Steven Shelton

There are two secrets to success in life
1) Never tell anybody everything you know

"K Dales" wrote in message
...
Sorry if not clear: it really doesn't matter where it goes as long as it
is
after this:

'inserts the row
Rows("3:3").Insert Shift:=xlDown, _
CopyOrigin:=xlFormatFromRightOrBelow

So right after that you could put:

' copies the formula:
Range(H3).Formula = "=IF(AND(ISBLANK(E3),ISBLANK(G3)),"",H4+E3-G3)"
--
- K Dales


"Wonderer" wrote:

I do not understand what you mean by "put this line of code someplace
after
you insert the new line" Please explain or give an example.

--

Steven Shelton

There are two secrets to success in life
1) Never tell anybody everything you know
"K Dales" wrote in message
...
It appears that column H has the balance formula - correct? Assuming
that
is
so, then put this line of code someplace after you insert the new
line:
Range(H3).Formula = "=IF(AND(ISBLANK(E3),ISBLANK(G3)),"",H4+E3-G3)

--
- K Dales


"Wonderer" wrote:

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











Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy trendline equation to cells for use in other calculations elaine101 Excel Discussion (Misc queries) 1 March 31st 09 06:36 PM
Ploynomial Trendline Equation Changes After Copy Paste Charles @ Aldenlab Charts and Charting in Excel 11 June 22nd 07 07:06 PM
copy a cell amt AFTER IF equation PatC Excel Worksheet Functions 1 March 20th 06 07:28 PM
Equation Editor- problem when editing an equation Gaby L. Excel Discussion (Misc queries) 0 September 27th 05 09:24 PM
How do I peg 4 col in an equation so when i add one col it only l. AVeraging Columns Excel Worksheet Functions 1 November 12th 04 07:10 PM


All times are GMT +1. The time now is 09:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"