A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Ok, looping through a validation list is quite a bit more complex, but still I have lifted an example from another website and slotted your code into this for you:
Sub CreatePDF()
Dim rng As Range
Dim dataValidationArray As Variant
Dim i As Integer
Dim rows As Integer
'Set the cell which contains the Data Validation list
Set rng = Range("K7")
'If Data Validation list is not a range, ignore errors
On Error Resume Next
'Create an array from the Data Validation formula, without creating
'a multi-dimensional array from the range
rows = Range(Replace(rng.Validation.Formula1, "=", "")).rows.Count
ReDim dataValidationArray(1 To rows)
For i = 1 To rows
dataValidationArray(i) = _
Range(Replace(rng.Validation.Formula1, "=", "")).Cells(i, 1)
Next i
'If not a range, then try splitting a string
If Err.Number <> 0 Then
Err.Clear
dataValidationArray = Split(rng.Validation.Formula1, ",")
End If
'Some other error has occured so exit sub
If Err.Number <> 0 Then Exit Sub
'Reinstate error checking
On Error GoTo 0
'Loop through all the values in the Data Validation Array
For i = LBound(dataValidationArray) To UBound(dataValidationArray)
'Change the value in the data validation cell
rng.Value = dataValidationArray(i)
'Force the sheet to recalculate
Application.Calculate
Dim ID As String
ID = rng.Text
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:="J:\All Staff\Student Data\2020 2021\Maths Sheets\" + ID + ".pdf", _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Next i
End Sub