View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.misc
EK EK is offline
external usenet poster
 
Posts: 20
Default Populate Data In Rows

One other thing. From this macro, what do I need to change in order to
re-populate with a different definition such as:
A=6 times, B=3 times, C=2 times and D=1 time.

EK
"EK" wrote:

I think I got the answer from this macro. Appreciate all who tried to the
help. Thanks!

"Gary''s Student" wrote:

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