Excel VBA Pasting Common Data Until Encountering Empty Cell - TechRepublic
Question
May 20, 2008 at 05:52 AM
christopher66

Excel VBA Pasting Common Data Until Encountering Empty Cell

by christopher66 . Updated 18 years, 2 months ago

Dear Friends,

I am looking to paste the contents of an order form to another worksheet which will have the header data pasted with each line item from the order. As it stands now, the data I need is only pasting to the first line. Is there a way to loop the pasting process until the script encounters a blank value in an adjacent cell? My code is listed below. Thanks in advance.

Private Sub SubmitBtn_Click()
If Range(“A19”) <> “” Then
Range(“A19:A48”).Copy
Sheet5.Range(“F602:F65536”).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Range(“B19:B48”).Copy
Sheet5.Range(“G602:G65536”).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Range(“H19:H48”).Copy
Sheet5.Range(“H602:H65536”).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Range(“Requester”).Copy
Sheet5.Range(“A602:A65536”).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Range(“Location”).Copy
Sheet5.Range(“B602:B65536”).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Range(“DateReq”).Copy
Sheet5.Range(“C602:C65536”).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Range(“DateNeeded”).Copy
Sheet5.Range(“D602:D65536”).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Range(“JobNumber”).Copy
Sheet5.Range(“E602:E65536”).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
End If
OrderSent.Show
End Sub

This discussion is locked

All Comments