0
"Sheet1"タブに入力した情報に基づいて異なる形式(vlookupの式を使用して)で異なる形式の見本を作成しようとしています。すべてのワークシートが作成されたら、これらのステートメントをPDFに出力してください。私は、新しく作成されたワークシート上のK1の数字が「シート1」に対応するように、行を下に移動するのではなく、「シート1」のセルA4にある番号を保持している問題を実行しています。 "Sheet1"の次の行。新しく作成されたタブへのVBAルーピング
Sub TEST()
'
' TEST Macro
'
'
On Error Resume Next
Dim MyCell As Range, MyRange As Range
Set MyRange = Sheets("Sheet1").Range("A4")
Set MyRange = Range(MyRange, MyRange.End(xlDown))
With ThisWorkbook
For Each MyCell In MyRange
.Sheets("Sample").Copy After:=Sheets(Sheets.Count)
.Sheets(Sheets.Count).Name = MyCell.Value
Next
Sheets("Sheet1").Select
FinalRow = Cells(Row.Count, 1).End(xlUp).Row
For x=4 to Final Row
.Sheets("Sheet1").Range("A5").Copy _
Destination:=Worksheets(Sheets.Count).Range("K1")
Next
End With
Dim FolderPath As String
FolderPath = "XXX"
For I = 1 To Worksheets.Count
Worksheets(I).ExportAsFixedFormat Type:=xlTypePDF, Filename:=FolderPath & "\" & _
Worksheets(I).Name, openafterpublish:=True
Next
MsgBox "All PDF's have been successfully exported"
End Sub