Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Macro to populate data (repeating rows)

Hello,

Need help with code for repeating an entire row (x) amount of times. Data
exists in columns A, B, C, and the (x) is the qty listed in column B. I.e.
in the example below, I would want apples to repeat 18 times, and pears to
repeat 12 times.

A B C
APPLES 18 4.95
PEARS 12 2.95

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 471
Default Macro to populate data (repeating rows)

Sub doit()
dim x as double
Dim DataArray(100,3) as variant
Dim Fnd as double
Dim Z as double
Dim y as double
Dim OnRow as double

cells(1,1).select
x=1
do while true
if cells(x,1).value=empty then exit do
fnd=fnd+1
dataarray(fnd,1)=cells(x,1).value
dataarray(fnd,2)=cells(x,2).value
Dataarray(fnd,3)=cells(x,3).value
x=x+1
Loop

sheets("sheet2").select
OnRow=0
for x=1 to fnd
for Y=1 to Dataarray(x,2)
onrow=onrow+1
cells(onrow,1).value=dataarray(X,1)
cells(onrow,2).value=dataarray(x,2)
cells(onrow,3).value=dataarray(X,3)
next
Next
end sub


A B C
APPLES 18 4.95
PEARS 12 2.95

Thanks!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate Data In Rows EK Excel Discussion (Misc queries) 9 October 25th 07 07:42 AM
When repeating city want zipcode to populate jrw - esq. New Users to Excel 2 February 22nd 07 10:48 AM
Lift Data from Rows to Populate HTML Variables [email protected] Excel Discussion (Misc queries) 1 August 1st 06 01:30 PM
How do I import external data populate rows instead of columns. KWE39 Excel Discussion (Misc queries) 0 July 1st 05 09:53 PM
help with macro to save repeating data entry Tom Excel Discussion (Misc queries) 0 February 16th 05 04:24 AM


All times are GMT +1. The time now is 04:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"