Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
hsg hsg is offline
external usenet poster
 
Posts: 40
Default add rows with copy format of previous row

My worksheet contains following data:

a b c d
list total cost of balance
funds item fund
-----------------------------------------------------
r1 item1 2500.00
r2 item2 3000.00
r3 item3 2000.00
r4 TOTAL 50000.00 7500.00 42500.00

As I add another item, selecting cell a3,
r4 should shift one row down, with c4 becoming
c5 and the formula should become sum(c1:c4)

format of row 3 (font, colour etc) should get copied to row4

Please help how to achieve this with macro
(either by writting macro or through macro recorder).

thanks

harsh
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 139
Default add rows with copy format of previous row

hi
Try following though I am sure there is better way you run macro while in
total cell
Sub macronewrow()
If ActiveCell.Value = "total" Then
ActiveCell.EntireRow.Select
Selection.Insert Shift:=xlDown
ActiveCell.Offset(0, 2).Name = "myend"
Range("c2").Name = "mystart"
ActiveCell.Offset(1, 2) = "=sum(mystart:myend)"
Else
MsgBox "you must be in "total" cell"
End If
End Sub
"hsg" wrote:

My worksheet contains following data:

a b c d
list total cost of balance
funds item fund
-----------------------------------------------------
r1 item1 2500.00
r2 item2 3000.00
r3 item3 2000.00
r4 TOTAL 50000.00 7500.00 42500.00

As I add another item, selecting cell a3,
r4 should shift one row down, with c4 becoming
c5 and the formula should become sum(c1:c4)

format of row 3 (font, colour etc) should get copied to row4

Please help how to achieve this with macro
(either by writting macro or through macro recorder).

thanks

harsh

  #3   Report Post  
Posted to microsoft.public.excel.programming
hsg hsg is offline
external usenet poster
 
Posts: 40
Default add rows with copy format of previous row

thanks tina, it works after changing total to TOTAL.
However it works even if the line ActiveCell.Offset(1, 2) =
"=sum(mystart:myend)"
just before Else is removed.

thanks anyway,

"tina" wrote:

hi
Try following though I am sure there is better way you run macro while in
total cell
Sub macronewrow()
If ActiveCell.Value = "total" Then
ActiveCell.EntireRow.Select
Selection.Insert Shift:=xlDown
ActiveCell.Offset(0, 2).Name = "myend"
Range("c2").Name = "mystart"
ActiveCell.Offset(1, 2) = "=sum(mystart:myend)"
Else
MsgBox "you must be in "total" cell"
End If
End Sub
"hsg" wrote:

My worksheet contains following data:

a b c d
list total cost of balance
funds item fund
-----------------------------------------------------
r1 item1 2500.00
r2 item2 3000.00
r3 item3 2000.00
r4 TOTAL 50000.00 7500.00 42500.00

As I add another item, selecting cell a3,
r4 should shift one row down, with c4 becoming
c5 and the formula should become sum(c1:c4)

format of row 3 (font, colour etc) should get copied to row4

Please help how to achieve this with macro
(either by writting macro or through macro recorder).

thanks

harsh

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 and Paste Format in filtered rows XLFanatico Excel Discussion (Misc queries) 6 July 24th 09 05:53 PM
Copy conditional format to rows below Hoot Excel Worksheet Functions 3 December 24th 08 04:41 PM
Need A Macro To Copy Previous Tab to New Tab MGC Excel Discussion (Misc queries) 8 August 15th 07 04:18 AM
Macro to copy previous row and insert two blank rows dd Excel Discussion (Misc queries) 1 April 30th 07 11:25 PM
How to copy rows from Excel without losing the row height format artex boy Excel Discussion (Misc queries) 1 September 20th 05 02:41 AM


All times are GMT +1. The time now is 11:11 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"