spacezaap
03-22-2018, 01:35 PM
Can you please tell me what is wrong with below code? It does what it's supposed to except naming the pdf file properly.
Bolded line seems to be the problem. Files are saved but each with the worksheet name instead of what is the the cell D2.
Thanks in advance for your input...
Tom
Sub mak()
Do Until (Range("A2") = "")
Sheets("Arkusz1").Range("A2").Copy
Sheets("Arkusz2").Activate
Range("D17").Select
ActiveSheet.Paste
Sheets("Arkusz1").Range("C2").Copy
Sheets("Arkusz2").Activate
Range("D14").Select
ActiveSheet.Paste
Sheets("Arkusz1").Range("E2").Copy
Sheets("Arkusz2").Activate
Range("D20").Select
ActiveSheet.Paste
Sheets("Arkusz1").Range("K2").Copy
Sheets("Arkusz2").Activate
Range("D6").Select
ActiveSheet.Paste
ActiveSheet.ExportAsFixedFormat Filename:=Range("D2").Value, Type:=xlTypePDF
Sheets("Arkusz1").Activate
Rows(2).EntireRow.Delete
Loop
End Sub
Bolded line seems to be the problem. Files are saved but each with the worksheet name instead of what is the the cell D2.
Thanks in advance for your input...
Tom
Sub mak()
Do Until (Range("A2") = "")
Sheets("Arkusz1").Range("A2").Copy
Sheets("Arkusz2").Activate
Range("D17").Select
ActiveSheet.Paste
Sheets("Arkusz1").Range("C2").Copy
Sheets("Arkusz2").Activate
Range("D14").Select
ActiveSheet.Paste
Sheets("Arkusz1").Range("E2").Copy
Sheets("Arkusz2").Activate
Range("D20").Select
ActiveSheet.Paste
Sheets("Arkusz1").Range("K2").Copy
Sheets("Arkusz2").Activate
Range("D6").Select
ActiveSheet.Paste
ActiveSheet.ExportAsFixedFormat Filename:=Range("D2").Value, Type:=xlTypePDF
Sheets("Arkusz1").Activate
Rows(2).EntireRow.Delete
Loop
End Sub