I have been using Application.Caller in a comparison in my code. When a user clicks a commandbutton, I am assuming Application.Caller returns the name of the command button,
As shown in that link, Application.Caller
will not always be of String
type
You are using StrComp
which compares 2 strings. I would recommend using this.
Sub Sample()
If TypeName(Application.Caller) = "String" Then
MsgBox StrComp(Application.Caller, "Button1")
End If
End Sub
And assign this macro to the Form Button which you have on the worksheet.
If you see the example given in the link that I gave earlier, it automatically will be clear to you :)
Select Case TypeName(Application.Caller)
Case "Range"
v = Application.Caller.Address
Case "String"
v = Application.Caller
Case "Error"
v = "Error"
Case Else
v = "unknown"
End Select