Inserting "template" rows

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
 
O

Otto Moehrbach

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"
 
O

Otto Moehrbach

Jenny
I've got it done but I have lost your email address. Get back to me.
Otto
"shikamikamoomoo"
 
A

aaron.kempf

you know; if you kept your DATA in a DATABASE you could just set the
defaults for new rows.

-aaron
 
G

greaseman

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top