Expanding a list

  • Thread starter littleredhairedgirl
  • Start date
L

littleredhairedgirl

I have a list of words in column A and a number in column B.

On a new sheet I would like to take the word and repeat it across
columns the number of time in column B (in the 1st Sheet)

so that

word 3
list 4
only 2

would be

word word word
list list list list list
only only
 
D

Don Guillett

Sub reptacross()
With Sheets("sheet1")
For i = 1 To .Cells(Rows.Count, "a").End(xlUp).Row
Sheets("sheet2").Cells(i, "a") _
..Resize(, .Cells(i, "b")) = .Cells(i, "a")
Next i
End With
End Sub
 
S

Shane Devenshire

Hi,

You can use the following formula approach:
=IF(COLUMN()>Sheet2!$B1,"",Sheet2!$A1)
Enter this in A1 of the sheet where you want the results and copy it down
and over as far as you like. If the first formula is not goint to be in A1,
say C2, then modify the formula
=IF(COLUMN()-2>Sheet2!$B1,"",Sheet2!$A1)
 
Top