dimanche 7 juin 2020

Excel VBA userform throwing error when checkbox = true in If Then Else Statement

Throwing an error for the following code. The error code says, "Compile error: Expected: Then or Go to"

Here's the code is having issues with.

Private Sub Userform.Initialize()
    If Worksheets("Sheet1").Range("P1").Value = "Y"
            Then
            CheckBox1.Value = True
            Else
            CheckBox1.Value = False
    End If
End Sub

Any insight on how to correct this error? I feel like the code is solid.

Aucun commentaire:

Enregistrer un commentaire