View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Populate Data In Rows

First sort your data by column B and then run:

Sub temp()
n = Cells(Rows.Count, 1).End(xlUp).Row
k = 1
For nn = 1 To n
nt = 69 - Asc(Cells(nn, 2).Value)
v = Cells(nn, 1).Value
For times = 1 To nt
Cells(k, 3).Value = v
k = k + 1
Next
Next
End Sub

--
Gary''s Student - gsnu200750


"EK" wrote:

I have following data:

A B
-----------------
Apples A
Pears D
Orange C
Grapes B

If column B is "A", repeat corresponding column A data 4 times in a row. If
column B is "B", repeat data 3 times in a row, and so forth. Please help with
solution which will result in the following:

column C
----------
Apples
Apples
Apples
Apples
Grapes
Grapes
Grapes
Orange
Orange
Pears