Hello,
I'm trying to write a macro that will look up the value from a specific row (which varies as I go down the worksheet) in column M (i.e. 24, but can be any number) and in return, copy and past the value from column D down that many times, remaining in column D. I also do NOT want the cells to be inserted, thus pushing the contents below this original copy and paste function in column D. Any help is appreciated. Here is what I have so far, but seems to be just missing the mark, because it inserts the values, and pushes the remaining data down, thus skewing my remaining data.
Sub DONT_DELETETest_To_Copy_and_Paste_Data()
Dim lRow As Long
Dim RepeatFactor As Variant
lRow = 1
Do While (Cells(lRow, "D") <> "")
RepeatFactor = Cells(lRow, "M")
If ((RepeatFactor > 1) And IsNumeric(RepeatFactor)) Then
Range(Cells(lRow, "D"), Cells(lRow, "D")).Copy
Range(Cells(lRow + 1, "D"), Cells(lRow + RepeatFactor - 1, "D")).Select
Selection.Insert Shift:=x1Down
lRow = lRow + RepeatFactor - 1
End If
lRow = lRow + 1
Loop
End Sub