Reputation: 312
I am trying to pass a variable(string) to a sub which is in module1 of my workbook using application.on time method. the below code is runing fine
Sub calar()
strText = "appl"
Application.OnTime Now + TimeValue("00:00:02"), "!Module1.cld"
End Sub
Sub cld()
MsgBox ("called" & slk)
End Sub
But when I try to pass an argument as shown below, I am getting an error:
Sub calar()
strText = "appl"
Application.OnTime Now + TimeValue("00:00:02"), "'!Module1.cld ""Hello!""'"
End Sub
Sub cld(ByVal slk As String)
MsgBox ("called" & slk)
End Sub
I want to pass strText as an argument please help.
Upvotes: 0
Views: 1266
Reputation: 8124
Try removing the first exclamation point...
Application.OnTime Now + TimeValue("00:00:02"), "'Module1.cld ""Hello!""'"
To pass a variable...
Application.OnTime Now + TimeValue("00:00:02"), "'Module1.cld """ & strText & """'"
Upvotes: 2