試試這個
Option Explicit
Sub LabelPrint()
Dim skuNumberSht As Worksheet, labelsSht As Worksheet
Dim iniRow As Long, lastRow As Long
Set skuNumberSht = ThisWorkbook.Sheets("SkuNumber") ' <== change "input" sheet name as per your needs
Set labelsSht = ThisWorkbook.Sheets("Labels") ' <== change "output" sheet name as per your needs
With skuNumberSht.Columns("B").SpecialCells(xlCellTypeConstants, xlNumbers) '<== change "Qty" column index as per your needs
iniRow = .Rows(1).Row
lastRow = .Areas(.Cells.Count).Row
End With
With labelsSht.Cells(iniRow, 1).Resize(2)
.Formula = Application.WorksheetFunction.Transpose(Array("=" & skuNumberSht.Name & "!RC", "=" & skuNumberSht.Name & "!R[-1]C[+1]"))
.Copy .Resize(lastRow - iniRow + 2)
End With
End Sub
你的作品有「輸入」張只要任何行,因爲他們是「配對」(行與兩列數據和一個空白行)
您只需根據需要更改工作表名稱和列索引中的「數量」即可。