Hello, I'm currently using the following VBA to save files from a list of employee IDs to PDF files. Currently, the coding is saving the files with the employee IDs, but I'd like to change this to the employee names. Does anyone know what I need to do to update the below?
'Declare variables
Dim ws As Worksheet
Dim rngID As Range
Dim rngListStart As Range
Dim rowsCount As Long
Dim i As Long
Dim pdffilepath As String
Dim tempPdfFilePath As String
'Stop screen updating during running
Application.ScreenUpdating = False
'Reference the Report Sheet
Set ws = ActiveWorkbook.Sheets("Sample Statement")
'Reference Employee ID cell
Set rngID = ws.Range("G5")
'Reference the start of the employee list
Set rngListStart = ws.Range("Q10")
'Refeence the pdfFilePath
pdffilepath = "W:\Long Term Incentive Awards\PAYOUTS\2013 OICP\2024 January RSU Vestings\US Employees\STATEMENTS\LTI Vesting Statement - [ID].pdf"
'Count the number of employee ID
rowsCount = rngListStart.CurrentRegion.Rows.Count - 1
For i = 1 To rowsCount
'Change the current employee ID
rngID.Value = rngListStart.Offset(i - 1, 0).Value
'Replace [ID] with the current employee ID
tempPdfFilePath = Replace(pdffilepath, "[ID]", rngID.Value)
'Create the PDFs
ws.ExportAsFixedFormat Type:=xlTypePDF, Filename:=tempPdfFilePath
Next i
'Restart screen updating during running
Application.ScreenUpdating = True
End Sub
'Declare variables
Dim ws As Worksheet
Dim rngID As Range
Dim rngListStart As Range
Dim rowsCount As Long
Dim i As Long
Dim pdffilepath As String
Dim tempPdfFilePath As String
'Stop screen updating during running
Application.ScreenUpdating = False
'Reference the Report Sheet
Set ws = ActiveWorkbook.Sheets("Sample Statement")
'Reference Employee ID cell
Set rngID = ws.Range("G5")
'Reference the start of the employee list
Set rngListStart = ws.Range("Q10")
'Refeence the pdfFilePath
pdffilepath = "W:\Long Term Incentive Awards\PAYOUTS\2013 OICP\2024 January RSU Vestings\US Employees\STATEMENTS\LTI Vesting Statement - [ID].pdf"
'Count the number of employee ID
rowsCount = rngListStart.CurrentRegion.Rows.Count - 1
For i = 1 To rowsCount
'Change the current employee ID
rngID.Value = rngListStart.Offset(i - 1, 0).Value
'Replace [ID] with the current employee ID
tempPdfFilePath = Replace(pdffilepath, "[ID]", rngID.Value)
'Create the PDFs
ws.ExportAsFixedFormat Type:=xlTypePDF, Filename:=tempPdfFilePath
Next i
'Restart screen updating during running
Application.ScreenUpdating = True
End Sub