green_world07
New Member
- Joined
- Jan 3, 2022
- Messages
- 11
- Office Version
- 365
- 2019
- Platform
- Windows
I want to convert ranges of rows in excel to pdf file with vba.but with specific format in a different sheet. Which I have done so far. But the problem is , some how my code is ignoring the rows with similar values. I want to add all the rows with similar values under the pdf file. for example: the first image shows how the data are in the data set and second image is the format of the output and I want EmpID as input and the related rows with that EmpID will be the output and the rows will be included sequentially in the output format like the third image expected output. below I have added the code i have added in the VBA to have the pdf. The problem i am facing is it generates the output of only one row with the number for example 430 and ignores other 5 of them and it goes for the next unique number and print that because other columns related to that rows contain information which have to be included in the pdf. Thanks a lot in advance. I have tried to solve it with a dropdown list of EmpID but my file is huge(18000 list of EmpID). So i think VBA is the only option to automatize the process.
Sub pdf_test_7()
Dim i As Integer
For i = 2 To 10
Sheets("ps").Cells(1, 2) = Sheets("WD").Cells(i, 1)
Sheets("ps").Range("A1:Q25").ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="C:\Users\Desktop\test_code_for_printing_pdf\" & Sheets("WD").Cells(i, 1) & ".pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=True, _
OpenAfterPublish:=False
Next i
End Sub
Sub pdf_test_7()
Dim i As Integer
For i = 2 To 10
Sheets("ps").Cells(1, 2) = Sheets("WD").Cells(i, 1)
Sheets("ps").Range("A1:Q25").ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="C:\Users\Desktop\test_code_for_printing_pdf\" & Sheets("WD").Cells(i, 1) & ".pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=True, _
OpenAfterPublish:=False
Next i
End Sub