Thread: Looping
View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
maju maju is offline
external usenet poster
 
Posts: 19
Default Looping

Thanks for all ur help. code adjusted but if is # 2, i want just i additional
row & if 3, i want 2 additional row etc. it is not giving me that. it keeps
giving me 2 addiotnal row for 2 and 3 additional row for 3.

"Don Guillett" wrote:

Your Original Post is what I used. Adjust accordingly.
1,no new row. if is it 2, 2 additional row with
same datas info, if 3, 3 additional rows with same data. thanks


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"maju" wrote in message
...
ok. thanks. I ran the code but i want it to give me for example, if the
quantity is 2, then i will get 1 extra row with data inserted, if 3, 2
rows
inserted etc

"Don Guillett" wrote:

Try

Sub insertandcopy()
mc = "c"
For i = Cells(Rows.Count, mc).End(xlUp).Row To 2 Step -1
mv = Cells(i, mc)
If mv 1 Then
Rows(i).Copy
Rows(i).Resize(mv).Insert
End If
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"maju" wrote in message
...
Hi Guys. I am new to macro programming. Below is my data. I need to
write
a
loop that will insert new row with same data whenever the quantity is
2, 3
etc. e.g if the quantity is 1,no new row. if is it 2, 2 additional row
with
same datas info, if 3, 3 additional rows with same data. thanks

State Style Quantity
Maryland 100g 1
New york xzy10 1
texas 200g 2
OH 3