Duplicate entry "x" number of times

G

Guest

Here is my dilemma. I have an entry in column A. I need this entry duplicates
the amount of times by the number in column b (if column b was 20 would
populate the entry from column A in columns c-v). I have about 50 rows that I
need duplicated and some need to be done 3 times and others 70 times. How can
this be done?
 
D

Dave Peterson

Maybe just a small macro:

Option Explicit
Sub testme()

Dim FirstRow As Long
Dim LastRow As Long
Dim iRow As Long
Dim HowMany As Variant

With Worksheets("sheet1")
FirstRow = 1 'no headers in row 1?
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For iRow = FirstRow To LastRow
'minor validation here
HowMany = .Cells(iRow, "B").Value
If IsNumeric(HowMany) Then
.Cells(iRow, "C").Resize(1, HowMany) = .Cells(iRow, "A").Value
End If
Next iRow
End With

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 

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

Similar Threads


Top