Hi, I'm following this youtube video to create a report that can be exported into PDFs with a macro. I want to add a date range to the filename and I can't figure out how to get it to work. I've put the date range in cell C6. Here is the macro I currently have, I've tried basically replicating the tempPDFFilePath replace part for the Date but it doesn't work so I've removed it here. This macro currently works perfectly it just doesn't give me the date in the filename. Any help would be appreciated!
VBA Code:
Sub SavePDFsFromList()
'Declare the 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 the screen updating while running
Application.ScreenUpdating = False
'Reference Report Sheet
Set ws = ActiveWorkbook.Sheets("Report")
'Reference the Tech name cell
Set rngID = ws.Range("C5")
'Reference the start of the Tech name List
Set rngListStart = ws.Range("N6")
'Reference dates
Set dateID = ws.Range("C6")
'Create the PDF File Name
pdfFilePath = "C:\Users\name\Documents\Reports\Combined Tech Bonus and Pay Adj\PDFs\Tech Pay - [ID].pdf"
'Count the rows in the Tech name List
rowsCount = rngListStart.CurrentRegion.Rows.Count - 1
For i = 1 To rowsCount
'Change the current tech name
rngID.Value = rngListStart.Offset(i - 1, 0).Value
'Replace [ID] with the Student ID Value
tempPDFFilePath = Replace(pdfFilePath, "[ID]", rngID.Value)
'Create the PDF
ws.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=tempPDFFilePath
Next i
'Restart the screen updating
Application.ScreenUpdating = True
End Sub