how to duplicate rows?

  • Thread starter Thread starter Marilyn
  • Start date Start date
M

Marilyn

I would like to know how I can duplicate rows.
Lets say I have a thousand names in column A IE: Bert, Ernie, Bob, John,
Fred... and so on. I need to have Bert, Bert, Bert, Ernie, Ernie, Ernie, Bob,
Bob, Bob, John, John, John, Fred, Fred, Fred, Fred... although I need then 5
or 6 times repeated not just 3!
 
Yes I need to repeat them. But keep them in the same order as they are now If
Bert came first, then Ernie… I still need Bert first, (repeated 3 times) and
then Ernie (3 times) and so on.
 
Either I need to learn how to guess better or you need to learn how to
explain better...
 
I really do not know how to explain this any easier that I did in my initial
question, Perhaps there may be someone else who can answer this question, I
have asked around within my own office and no one know how and no one knows
how I could explain it any other way that would be simpler. Thanks the
responses that you tried to assist me with.
 
Perhaps you could give an example???

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
Marilyn said:
I really do not know how to explain this any easier that I did in my
initial
question, Perhaps there may be someone else who can answer this question,
I
have asked around within my own office and no one know how and no one
knows
how I could explain it any other way that would be simpler. Thanks the
responses that you tried to assist me with.
 
Sub Add2Rows()
'insert 2 rows and fill down from above
Dim LastRow As Long, I As Long
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
For I = LastRow To 1 Step -1
Rows(I + 1).Resize(2).Insert
Rows(I).Resize(3).FillDown
Next I
End Sub

If you're not familiar with VBA and macros, see David McRitchie's site for
more on "getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

or Ron de De Bruin's site on where to store macros.

http://www.rondebruin.nl/code.htm

In the meantime..........

First...create a backup copy of your original workbook.

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + r to open Project Explorer.

Find your workbook/project and select it.

Right-click and Insert>Module. Paste the code in there. Save the
workbook and hit ALT + Q to return to your workbook.

Run or edit the macro by going to Tool>Macro>Macros.

You can also assign this macro to a button or a shortcut key combo.


Gord Dibben MS Excel MVP
 

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

Back
Top