Inserting "template" rows

  • Thread starter Thread starter shikamikamoomoo
  • Start date Start date
S

shikamikamoomoo

Hi...I have a payroll sheet that I need to insert 3 rows of copied tex
at each blank line. I'm sure there is a way to do this using VBA cod
or something of that sort, but I do not know how to do it. Simply pu
I need...

If the row is blank, insert rows 1:3 from sheet 2.....or even better i
I did not need to have "sheet two" and I could insert preset rows o
information.

If someone could please help me out or point me in the right directio
to find out how to do this I would really appreciate it. Thanks!

Jenn
 
Jenny

The attached macro will do what you want. I made up some text
for each of the 3 rows you want inserted so you will not need Sheet2. I
assumed your data started in A1 and went down. You will need to make
changes in this macro to have it work with your actual data. If you get an
error with this macro post back and tell us the version of Excel you are
using.

If you wish, send me a valid email address and I'll send you a
small file that has this macro properly placed. My email address is
(e-mail address removed). Remove the "nop" from this address. HTH Otto

Sub InsertData()
Dim RngA As Range
Dim c As Long
Dim First As String
Dim Second As String
Dim Third As String
First = "First row of data"
Second = "Second row of data"
Third = "Third row of data"
Set RngA = Range("A1", Range("A" & Rows.Count).End(xlUp))
For c = RngA.Count To 1 Step -1
If Cells(c, 1) = "" Then
Cells(c, 1).Offset(1).Resize(2).EntireRow.Insert
Cells(c, 1).Value = First
Cells(c + 1, 1).Value = Second
Cells(c + 2, 1).Value = Third
End If
Next c
End Sub

"shikamikamoomoo"
 
Jenny
I've got it done but I have lost your email address. Get back to me.
Otto
"shikamikamoomoo"
 
you know; if you kept your DATA in a DATABASE you could just set the
defaults for new rows.

-aaron
 
For cryin' out loud!! Even this long ago, Aaron was shoveling out the
bs! What a useless reply he gave!
 
Back
Top