Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Insert Blank Row Below Sub-Total? | Excel Worksheet Functions | |||
Insert Rows after word total | Excel Programming | |||
Autoatically insert blank row above total when no more rows | Excel Programming | |||
Inserting Copied Row To Always Insert Above Sub Total | Excel Worksheet Functions | |||
Insert Grand total at the end | Excel Programming |