LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default How To Insert 3 Rows and Total

Joel tks very much, I needed exactly the same macro, however for som or other
reason my macro doesn't work ?? I think it's got something to do with the ref
to the columns. In my spreadsheet the names appear in C and the amounts in D.
Any help would be appreciated
--
HJN


"Joel" wrote:

You didn't specify which columns you used so yo need to change the references
to Column A & b


Sub GetTotal()

RowCount = 1
StartRow = RowCount
Do While Range("A" & RowCount) < ""
If Range("A" & RowCount) < Range("A" & (RowCount + 1)) Then
'add 3 rows
Rows(RowCount + 1).Insert
Rows(RowCount + 1).Insert
Rows(RowCount + 1).Insert
'put formula for total
Range("B" & (RowCount + 2)).Formula = _
"=Sum(B" & StartRow & ":B" & RowCount & ")"
Range("A" & (RowCount + 2)) = "TOTAL"
RowCount = RowCount + 4
StartRow = RowCount
Else
RowCount = RowCount + 1
End If
Loop

End Sub


"ed.cabrera" wrote:

I've been knocking myself out since yesterday trying to figure
something out. I have some self-taught experience with VBA macros in
Excel, but just can't get this. And I bet it's simple. Here's the
deal:

I have a monthly spreadsheet that lists users and their cell phone
expenses. There is typically 4 - 6 rows for each user. I want to
write a macro that will look at the cell that contains the name,
compare it to the cell below it. Then if they match, move down one
cell and compare again. Then when it fines a difference, add 3 rows,
put a subtotal under the expense cells; and then go back to analyzing
the name cells looking for the next break and resume.

Is that confusing? Would anybody be able to help me out with
this ...I'd be very greatful!

Thanks

 
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
Insert Blank Row Below Sub-Total? Miss Jenny Excel Worksheet Functions 6 June 6th 08 08:22 PM
Insert Rows after word total Elaine Excel Programming 5 November 9th 06 11:27 PM
Autoatically insert blank row above total when no more rows Capsaisin Excel Programming 3 May 18th 06 11:55 PM
Inserting Copied Row To Always Insert Above Sub Total Jamess Excel Worksheet Functions 0 November 9th 05 11:09 PM
Insert Grand total at the end Payal[_2_] Excel Programming 1 April 9th 04 01:46 AM


All times are GMT +1. The time now is 06:00 AM.

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"