This one has thrown me a little as I don't understand why it is even throwing the error.
I have it breaking on class module so I can see it is falling over on "lastRow = Sheets(CStr(y)).Range("A5", Range("A5").End(xlDown)).Rows.Count + 4".
When debugging (although it still falls over)
y = "2023" Can confirm there is a sheet called 2023
lastRow = 0 Not yet populated
I have also tried putting ActiveWorkbook in front of the sheet, in case it was being weird about that. ActiveWorkbook.FullName also reports the correct workbook.
Private Sub UserForm_Initialize() Dim x As Integer Dim y As Integer Dim cellString As String Dim person As String Dim lastRow As Integer y = year(Now) If Month(Now) < 4 Then y = y + 1 End If ddlPosition.Clear lastRow = Sheets(CStr(y)).Range("A5", Range("A5").End(xlDown)).Rows.Count + 4 <- Errors here For x = 5 To lastRow cellString = "A" & x person = Sheets(CStr(y)).Range(cellString).Value If Len(person) > 0 And person <> "Events" Then ddlPosition.AddItem person End If Next End Sub