i have 2 sheets, Sheet 1 has the actual data and Sheet 2 has predefined label where i fetch values from sheet 1 and print using a loop. Currently it works fine as i send output directly to printer but i want to send output to a single PDF file. Below is the snapshot of how the label looks and also code i am using to print.
Sub PrintLabels()
Dim ws1 As Worksheet 'declare worksheet variables
Dim ws2 As Worksheet
Set ws1 = ThisWorkbook.Sheets("Sheet1") 'set worksheet variables to the relevant sheets
Set ws2 = ThisWorkbook.Sheets("Sheet2")
Dim row As Long 'declare row variables
row = 2 'start at row 2 on Sheet 1
Do While ws1.Cells(row, 1).Value <> "" 'loop until an empty cell is encountered
ws2.Cells(4, "D").Value = ws1.Cells(row, "A").Value
ws2.Cells(7, "D").Value = ws1.Cells(row, "D").Value
ws2.Cells(11, "D").Value = ws1.Cells(row, "H").Value
ws2.Cells(14, "D").Value = ws1.Cells(row, "I").Value
ws2.Cells(21, "D").Value = ws1.Cells(row, "L").Value
ActiveSheet.PrintOut 'Print active sheet
row = row + 1 'increment row on Sheet 1
Loop
End Sub
Sub PrintLabels()
Dim ws1 As Worksheet 'declare worksheet variables
Dim ws2 As Worksheet
Set ws1 = ThisWorkbook.Sheets("Sheet1") 'set worksheet variables to the relevant sheets
Set ws2 = ThisWorkbook.Sheets("Sheet2")
Dim row As Long 'declare row variables
row = 2 'start at row 2 on Sheet 1
Do While ws1.Cells(row, 1).Value <> "" 'loop until an empty cell is encountered
ws2.Cells(4, "D").Value = ws1.Cells(row, "A").Value
ws2.Cells(7, "D").Value = ws1.Cells(row, "D").Value
ws2.Cells(11, "D").Value = ws1.Cells(row, "H").Value
ws2.Cells(14, "D").Value = ws1.Cells(row, "I").Value
ws2.Cells(21, "D").Value = ws1.Cells(row, "L").Value
ActiveSheet.PrintOut 'Print active sheet
row = row + 1 'increment row on Sheet 1
Loop
End Sub