This code give me an "Compile Error: Expected Sub, Function, or Property". I had tried many ways but they no work also. Anyone can help me please?Please Login or Register to view this content.
This code give me an "Compile Error: Expected Sub, Function, or Property". I had tried many ways but they no work also. Anyone can help me please?Please Login or Register to view this content.
Replace the Call with Msgbox
If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
Mark your thread as Solved
If the suggestion helps you, then Click *below to Add Reputation
Hi sixthsense, thanks for your help.
But "Machine1" is a macro, I wanna call the macro instead of show them as a message.
There are couple of code in this subroutines, how can I call them? Or is that others code to trigger the macro in array?Please Login or Register to view this content.
Just define this In the Top Line of the Module (i.e.) in the first line of the module code
Dim test(1 To 3, 1 To 2) As Variant
So that it can be used in any of the procedures of that module
@sianjialin,
you need to do this.
Please Login or Register to view this content.
Happy Computing ,
Xlbiznes.
To show your appreciation please click *
do you meant to add the code Dim test(1 to 3, 1 to 2) as Variant into all the module to be call?
Is this what you mean?..If so, it doesn't work alsoPlease Login or Register to view this content.
hi xlbiznes,
I have try it but another error appear, I don't know how to solve it as I'm a beginner, sorry about that. The error message is as:
Run-Time error '1004': Cannot run the macro 'Machine1'. the macro may not be available in this workbook or all macros may be disabled.
What should I do? >_<
You macro needs to be inside a module.
To add a module :
a) Click Developer
b) Click Visual Basic
c) Click Insert and then Click Module
Yes, it is inside a module.
Sub Machine1() in Module1, I think no problem for this.
Surprising,
this runs perfectly, when i test it . Anyways take a look at this.
Read this....
Module Scope
Module scope means that a variable can be declared before and outside of any procedure in a regular code module. If you use Private or Dim to declare the variable, only procedures that are in the same module can access that variable. Since a module level variable is not part of any procedure, it will retain its value even after the procedure that changes its value has terminated. For example,
Dim ModVar As Long
The variable ModVar can be read or changed from any procedure in the same module as the declaration. However, it cannot be accessed from a procedure that resides in another module. Separate modules may declare variables with the same name (e.g., both Module1 and Module2 both can have a module-level variable named ModVar). Each module-level variable will be accessed by procedures within the same module. If both Module1 and Module2 have a module-level variable named ModVar, procedures within Module1 will access the variable ModVar defined within Module1 and procedures within Module2 will access the variable ModVar defined in Module2. Variables with the same name in separate modules are completely independent of one another, even though they have the same name.
You can use either Dim or Private to declare a module level variable that is accessible only within that module. That is, the following declarations are functionally equivalent.
Dim ModVar As Long
Private ModVar As Long
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks