Hello!

I have many labels on my userform that become visible if there is an error. (ErrorLabel1, ErrorLabel2, ErrorLabel3.... etc). If any are visible, I want to disable my submit button.

I created a FOR LOOP. I tried using "i" to distinguish between each ErrorLabel. However, the compiler doesn't recognize this as a Label Object. Is it possible to create a string and then convert the string to a label? I'm not sure how to do that though... Below is my latest attempt. Many thanks in advance for your help!

Private Function CheckForErrorMessages()
 
    Dim labelObj As label
      
    For i = 1 To ErrorLabelCount
   
        Set labelObj = "ErrorLabel" & i
 
        If labelObj.Visible = True Then
            SubmitButton.Enabled = False
            CheckForErrorMessages = True
            Exit For
        Else
            SubmitButton.Enabled = True
            CheckForErrorMessages = False
        End If
    Next i
 
 
End Function