I have a excel table in Cell B2:C2 to B10:C10 in sheet1. I need to copy this table "x" number of times as specifiedin A2, with an row offset (gap) of 10 rows starting D2 in sheet2.
But somehow, only the first row of the data is getting copied???
I have the following macro:
Sub CopyPaste()
Dim LRow As Integer
Dim LQty As Integer
Dim LProduct As String
Dim LColEPosition As Integer
Dim j As Integer
Dim LStart As Integer
Dim LEnd As Integer
'Search for values in column B starting at row 2
LRow = 2
'Copy values to column E starting at row 2
LColEPosition = 2
'LColEPosition = ActiveCell.Offset(rowOffset:=3, columnOffset:=3).Activate
'Search through values in column B until a blank cell is encountered
While Len(Range("B" & CStr(LRow)).Value) > 0
'Retrieve quantity and product name
LQty = Range("A" & CStr(LRow)).Value
LProduct = Range("B" & CStr(LRow)).Value
'Set start and end position for copy to column E
LStart = LColEPosition
LEnd = LColEPosition + LQty
'Copy product name the number of times that is given by the quantity
For j = LStart To LEnd - 1
Range("E" & CStr(j)).Value = LProduct
Next
'Update column E position
LColEPosition = LEnd
LRow = LRow + 1
Wend
End Sub
Pl help.....
Bookmarks