I recently started to learn excel vba and at the moment I am stuck calling Public Subroutine from a userform Excel VBA. I have been trying to put the subroutine into a module and few other places but still it gives me an error.(Sub or Function not defined!)
Can you please guide in the right direction.
The function itself in module1
Public Sub Check(j As Integer)
If Worksheets("VBA").Cells(j, 19).Value = "Y" Then
imgA.Visible = True
imgB.Visible = False
imgC.Visible = False
imgD.Visible = False
ElseIf Worksheets("VBA").Cells(j, 19).Value = "N" Then
imgA.Visible = False
imgB.Visible = True
imgC.Visible = False
imgD.Visible = False
ElseIf Worksheets("VBA").Cells(j, 19).Value = "X" Then
imgA.Visible = False
imgB.Visible = False
imgC.Visible = True
imgD.Visible = False
ElseIf Worksheets("VBA").Cells(j, 19).Value = "F" Then
imgA.Visible = False
imgB.Visible = False
imgC.Visible = False
imgD.Visible = True
End If
End Sub
Here I am calling it in a userform
Private Sub UserForm_Initialize()
Call Check(i)
End Sub
Call Module1.Check(i)
– DaveCall
and just haveModule1.Check i
- you won't need the parenthesis anyway – Dave