ChristianInc
01-31-2017, 02:34 AM
Hey VBA Express
I'm hoping someone can help me, since I have used quite a few hours looking for a response online.
I've got a macro in Excel 2016 that helps new users get a guide to a model, we've made. The code itself runs fine, but when I open the file once again, Excel comes up with following error messages:
18199
Followed by this one.
18200
I think I've narrowed the problem down to being with my buttons, that pass on two parameters.
The following, simplified code creates the same error-messages as the entire code does:
Sub testcode()Dim Parameter1, Parameter2 As String
Set cl = Range("Input1").Offset(offsetver, offsethor)
Set bu = ActiveSheet.Buttons.Add(cl.Left + 200, 100, 50, 20)
bu.OnAction = "'Test1 """ & Parameter1 & """,""" & Parameter2 & """ '"
End Sub
Sub Test1(Paramter1, Parameter2)
'do something
Debug.Print "It works"
End Sub
The question is: How can I pass on arguments to another sub, without creating the problems with the entire Excel-document?
I hope you can help me :)
I'm hoping someone can help me, since I have used quite a few hours looking for a response online.
I've got a macro in Excel 2016 that helps new users get a guide to a model, we've made. The code itself runs fine, but when I open the file once again, Excel comes up with following error messages:
18199
Followed by this one.
18200
I think I've narrowed the problem down to being with my buttons, that pass on two parameters.
The following, simplified code creates the same error-messages as the entire code does:
Sub testcode()Dim Parameter1, Parameter2 As String
Set cl = Range("Input1").Offset(offsetver, offsethor)
Set bu = ActiveSheet.Buttons.Add(cl.Left + 200, 100, 50, 20)
bu.OnAction = "'Test1 """ & Parameter1 & """,""" & Parameter2 & """ '"
End Sub
Sub Test1(Paramter1, Parameter2)
'do something
Debug.Print "It works"
End Sub
The question is: How can I pass on arguments to another sub, without creating the problems with the entire Excel-document?
I hope you can help me :)