View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
kden kden is offline
external usenet poster
 
Posts: 5
Default Macro to insert rows in Excel

gocush:

By any chance, did you happen to see/get my comment on this when I tried it?
I'm still trying to figure-out how to complete this task.

kden

"gocush" wrote:

From this description, I assume that you have sorted the list of transactions
on Col A. (All transactions for Acnt "A" are together, followed by all
transactions for Acnt "AB" etc)

If you just want to total the transactions for each acnt you should be able
to do this with the SUBTOTAL function: DataSubtotals See Help for
instructions

If you want to insert blank rows and create you own subtotal try the
following. The downside of this is that the blank rows are then hardcoded
and adding new transactions to you database might be difficult.

Option Explicit

Sub InsertRows()

Sub InsertRows()
Dim oCell As Range
Dim lTransCount As Long
Dim L As Long

lTransCount = Application.CountA(Columns(1))
For L = lTransCount To 2 Step -1
If Range("A" & L) < Range("A" & L).Offset(-1, 0) Then
MsgBox Range("A" & L).Offset(-1, 0).Address & " is the last row
for an acnt"
'Insert 3 blank rows
Range(Range("A" & L), Range("A" & L).Offset(2, 0)).Insert
xlShiftDown
End If
Next L
End Sub

"kden" wrote:

Column A is account numbers, with each row an individual transaction. So,
there may be thousands of transactions for a single account number. The macro
would search the numbers (in column A) and when there's a "new number"
(essentially, new transactions for a different account number), I'd like for
the macro to insert 2-3 rows at the end of each account so that I can sum the
debits/credits for the account.

"gocush" wrote:

Can you tell us what you mean by a "New number"

"kden" wrote:

I'm trying to create a macro which will search the data (text and/or number)
in column A. When it finds a new number, I would like to insert 2-3 rows at
the end of the previous number, then continue through the entire worksheet
doing the same thing.