我有一个包含表格名称的列表框。我需要将所有这些工作表合并为单个工作表并将其另存为PDF。
我需要知道下一页的第一行编号。请参阅下面的代码和评论:
For i = 0 To lstPrintSheet.ListCount - 1
Set oFindRange = WS_Print.Cells.Find("*", SearchOrder:=xlByRows, LookIn:=xlValues, SearchDirection:=xlPrevious)
If oFindRange Is Nothing Then
pRow = 1
Else
pRow = oFindRange.Row + 1
End If
' instead of above logic, I want to assign pRow with the 1st Row on the next page.
' So suppose after pasting the contents, if my last used row in WS_Print is 255 on page# 4, I want pRow to assign to 1st row of page# 5 (So that next sheet gets pasted on next page)
On Error Resume Next
Do
Err.Clear
ThisWorkbook.Sheets(lstPrintSheet.List(i)).UsedRange.Copy WS_Print.Range("A" & pRow)
pRow = pRow + 1
Loop While Err.Number <> 0
On Error GoTo 0
Next
对此有任何专家意见吗?