Repeat Values specified # of Times

skhaliq

New Member
Joined
Dec 24, 2011
Messages
17
[TABLE="width: 143"]
<colgroup><col style="text-align: center;"><col style="text-align: center;"></colgroup><tbody>[TR]
[TD="align: center"]no of Times[/TD]
[TD="align: center"]Name[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]Ali [/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]Adnan[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]Butt[/TD]
[/TR]
[TR]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]Result[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]Ali [/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]Ali [/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]Adnan[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]Adnan[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]Adnan[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]Adnan[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]Adnan[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]Butt[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]Butt[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]Butt[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]Butt[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Try

Code:
Sub test()
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
    Rows(i).Copy
    Rows(i).Resize(Range("A" & i).Value - 1).Insert
Next i
End Sub
 
Upvote 0
If you happen to have a lot of rows of original data, you might also try this as a faster alternative.
Code:
Sub Repeat()
  Dim a, b
  Dim rws As Long, i As Long, j As Long, k As Long, x As Long
  Dim s As String
  
  a = Range("A2", Range("B" & Rows.Count).End(xlUp)).Value
  rws = UBound(a, 1)
  ReDim b(1 To Rows.Count, 1 To 2)
  For i = 1 To rws
    x = a(i, 1)
    s = a(i, 2)
    For j = 1 To x
      k = k + 1
      b(k, 1) = x
      b(k, 2) = s
    Next j
  Next i
  Range("A2").Resize(k, 2).Value = b
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,264
Messages
6,171,081
Members
452,377
Latest member
bradfordsam

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
Back
Top