macro and insert rows and count

  • Thread starter Thread starter RichardO
  • Start date Start date
R

RichardO

Hello All:

I have the following column headings:

Name, Code, Analyst, Invoice, Bill Date, Due Date, Bal, Current
Incurred, Days Past, Now and Track.

1) I would like to create a macro that will insert 5 rows after
change in Analyst (I have 3 analysts Amanda, Eunice and Tamara). Als
I would like the macro to count how many times each analyst appears an
write the Analyst name and # in between the rows created.

Can anyone please tell me how to write this code?

Thanks a lot

Richardo
 
Here is one I posted recently for 10 rows

Sub insert10rows()
For i = 3 To 2 Step -1
Cells(i, "d").Resize(10, 1).EntireRow.Insert
Next i
End Sub

for you

Sub insert5rows()
LastRow = Cells(Rows.Count, "c").End(xlUp).Row
For i = LastRow To 2 Step -1
MsgBox Application.CountIf(Range("c:c"), Cells(i, "c"))
If Cells(i - 1, "c") <> Cells(i, "c") Then
Cells(i, "c").Resize(5, 1).EntireRow.Insert
End If
Next i
End Sub
 
Thanks, this is for Don and every other person that can help out.

The first row of my data is a header, how would this code change s
that it does not insert 5 rows after the header.

I appreciate your efforts, thanks.

One further question,

How do I insert a row after the end of every "YES" in columns L, M & N
So, for example, in column L, two consecutive YES may exist in row
and 3, I want to insert a row after row 3. Another example, ther
might be a YES in column N in row 6, 7&8, I want to insert a row afte
row 8. How do I add all these to the code provided earlier?

Thanks for your kind patience.

Are there websites that have tips for a beginner vba learner? I reall
want to understand and learn to code in it.

Richard
 
I have an additional Question if you dont mind, Don Guillett. what i
the "i" for in -----------

If Cells(i - 1, "c") <> Cells(i, "c") Then
Cells(i, "c").Resize(5, 1).EntireRow.Insert

im trying to insert 2 rows after any text in a single column.

Thank you in advance.

Kimme
 
It could have been anything such a xxx or mywhatever or bad.
In this case, it's just short for iteration and is quite common in excel vba
 
Back
Top