我有这个代码。它循环通过和改变一个值,然后打印,并重复。问题是,我的pdf只是最后一个循环值,它不添加每个变化作为一个单独的工作表在我的pdf。
Private Sub CommandButton1_Click()
For x = 1 To 100 'increase the 100 to a larger number if you ever have more than 100 sheets
If Sheets("Sheet2").Range("T" & x).Value = "" Then Exit Sub
Sheets("Sheet2").Range("F4").Value = Sheets("Sheet2").Range("T" & x).Value
Sheets("Sheet2").Range("F3").Value = Sheets("Sheet2").Range("U" & x).Value
'For Each ws In ActiveWorkbook.Worksheets
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF
Next
End Sub
尝试了代码,预期20张的PDF,但只得到了1,我的范围的最后一个值。
1条答案
按热度按时间nhjlsmyf1#
这对我想要的很有效。