Satya Ranjan
New Member
- Joined
- Dec 23, 2015
- Messages
- 26
Each line is to be repeated by the nos of qty and in each line qty will be 1.
Is there any way we can do this in excel?
Thanks
Sub MM1()
Dim i As Long
With Sheets("Sheet1")
For i = 4 To Range("A" & Rows.Count).End(xlUp).Row
.Range("A" & i & ":C" & i).Copy Destination:=Range("E" & Rows.Count).End(xlUp).Offset(1).Resize(.Range("C" & i).Value)
Next i
End With
Range("G4:G" & Range("G" & Rows.Count).End(xlUp).Row).Value = 1
End Sub
Thats what my code does !!!
Is your source data in columns A to C ??
I'm sorry! I think I was not able to explain my requirement properly.
Consider the source Data is present on sheet 1 and there are 1000 lines. like below.
Item Qty
A 4
B 5
C 4
D 7
I want them to be splited in sheet 2 like below.
Item Qty
A 1
A 1
A 1
A 1
B 1
B 1
B 1
B 1
B 1
D 1
D 1
D 1
D 1
D 1
D 1
D 1
Try,
1] Sheet 2 A2, formula copy down :
=LOOKUP(ROWS(A$1:A1),SUMIF(OFFSET(Sheet1!B$1,,,ROW($1:$1000),),"<>")+1,Sheet1!A$2:A$1000)&""
2] Sheet 2 B2, formula copy down :
=IF(A2<>"",1,"")
Regards