Creating Duplicate Cells Based on Criteria

jrowland

New Member
Joined
Jul 3, 2009
Messages
7
Hello,

I need to create a macro that will duplicate cells a set number of times based on criteria in another cell. For example, I have:

Code:
A1             B1
John          3
Mike          1
Bill            5
And I would like to have:

Code:
A1
John
John
John
Mike
Bill
Bill
Bill
Bill
Bill
http://www.mrexcel.com/forum/showthread.php?t=431282

Is pretty close to what I'm looking for, but I couldn't adapt that code to work with my present list.

Thank you for your time.
 

Some videos you may like

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try

Code:
Sub Rpts()
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
Columns("A").Insert
For i = 1 To LR
    Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(Range("C" & i)).Value = Range("B" & i).Value
Next i
Columns("B").Delete
Range("A1").Delete
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,122,491
Messages
5,596,466
Members
414,069
Latest member
StudExcel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top