PDA

View Full Version : [SOLVED:] Call Sub in module from userform



LemonBradder
02-25-2014, 09:42 AM
Hi all,Hope everything is going well.I am working in excel 2010 and have googled solutions to parts of my problem but can not get them to work togther. What I want is in a userform the following:


Private Sub RunButton_Click() ' Not to be accessed from view macros
Dim String As String, StringArray1() As String, StringArray2() As String

'Code to make Strings and arrays that works
Call Modules!myModule.mySub(String ,StringArray1,StringArray2)
'Modules are in the same VBAProject as Userform
Unload myUserform
End Sub

I appreciate any help guys, this is the last thing I need to get a new tool working and it has got me stumped! Sorry about the no carriage return I will try again in a few hours on a different computer

LemonBradder
02-25-2014, 09:48 AM
Hi all,Hope everything is going well.I am working in excel 2010 and have googled solutions to parts of my problem but can not get them to work togther. What I want is in a userform the following:Private Sub RunButton_Click() ' Not to be accessed from view macrosDim String As String, StringArray1() As String, StringArray2() As String'Code to make Strings and arrays that worksCall Modules!myModule.mySub(String ,StringArray1,StringArray2)'Modules are in the same VBAProject as UserformUnload myUserformEnd SubI appreciate any help guys, this is the last thing I need to get a new tool working and it has got me stumped!

Bob Phillips
02-25-2014, 10:20 AM
So that is what you want, what are you getting? What is the problem?

LemonBradder
02-26-2014, 01:02 AM
Sorry, I think the line:
Call Modules!myModule.mySub(String ,StringArray1,StringArray2) is a is not the correct syntax because it throws up the error "Expected . or )"

LemonBradder
02-26-2014, 01:11 AM
It works without the Modules!, thanks anyway.

Bob Phillips
02-26-2014, 01:14 AM
You can't call a variable String, that is a datatype, and you don't say Modules!myModule


Private Sub RunButton_Click() ' Not to be accessed from view macros
Dim StringA As String, StringArray1() As String, StringArray2() As String

'Code to make Strings and arrays that works
Call myModule.mySub(StrinAg ,StringArray1,StringArray2)
'Modules are in the same VBAProject as Userform
Unload myUserform
End Sub