Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 293
Default Syntax Error '1004'

Greetings,

I am attempting to run this macro :

For this example x equals 1, 2 or 3. vName & vNum together is the
name of the originating TextBox.

Here is the code fragment in question:

Run "InvCol_" & x, vName, vNum

This will run one of the three procedures known as InvCol_1, InvCol_2
or InvCol_3 each with the pass though arguments of vName & vNum.

The problem is the VB error message:

Run-time error '1004'
The macro 'InvCol_1' cannot be found.

VB is calling it a macro, I'm not sure if that means anything or not.
The full name of the procedure is:

Public Sub InvCol_1(vName As Variant, vNum As Variant)

It is in the UserForm code area as is the rest of this code, It was
working until I changed the calling method to include a variable to
simplify the code.

Can anyone see what I did wrong to mess up this code and, more
importantly, how do I fix it?

Any help will be appreciated.

-minitman
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 143
Default Syntax Error '1004'

i think you need put InvCol_1 and the others in a regular module.

"Minitman" wrote in message
...
| Greetings,
|
| I am attempting to run this macro :
|
| For this example x equals 1, 2 or 3. vName & vNum together is the
| name of the originating TextBox.
|
| Here is the code fragment in question:
|
| Run "InvCol_" & x, vName, vNum
|
| This will run one of the three procedures known as InvCol_1, InvCol_2
| or InvCol_3 each with the pass though arguments of vName & vNum.
|
| The problem is the VB error message:
|
| Run-time error '1004'
| The macro 'InvCol_1' cannot be found.
|
| VB is calling it a macro, I'm not sure if that means anything or not.
| The full name of the procedure is:
|
| Public Sub InvCol_1(vName As Variant, vNum As Variant)
|
| It is in the UserForm code area as is the rest of this code, It was
| working until I changed the calling method to include a variable to
| simplify the code.
|
| Can anyone see what I did wrong to mess up this code and, more
| importantly, how do I fix it?
|
| Any help will be appreciated.
|
| -minitman

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 293
Default Syntax Error '1004'

Hey Homey,

Thanks for the reply.

I tried to move the 7 subs. The use of Me.Controls() was not
recognized in a standard module. There may have been other problems
that had not shown up as well. I had to take the code back and call
the macros without the variables (add a select case layer to choose
the correct macro to run - oh well)

Again, thanks for the effort
-Minitman
On Mon, 18 Jan 2010 09:31:13 -0500, "Homey" <none wrote:

i think you need put InvCol_1 and the others in a regular module.

"Minitman" wrote in message
.. .
| Greetings,
|
| I am attempting to run this macro :
|
| For this example x equals 1, 2 or 3. vName & vNum together is the
| name of the originating TextBox.
|
| Here is the code fragment in question:
|
| Run "InvCol_" & x, vName, vNum
|
| This will run one of the three procedures known as InvCol_1, InvCol_2
| or InvCol_3 each with the pass though arguments of vName & vNum.
|
| The problem is the VB error message:
|
| Run-time error '1004'
| The macro 'InvCol_1' cannot be found.
|
| VB is calling it a macro, I'm not sure if that means anything or not.
| The full name of the procedure is:
|
| Public Sub InvCol_1(vName As Variant, vNum As Variant)
|
| It is in the UserForm code area as is the rest of this code, It was
| working until I changed the calling method to include a variable to
| simplify the code.
|
| Can anyone see what I did wrong to mess up this code and, more
| importantly, how do I fix it?
|
| Any help will be appreciated.
|
| -minitman


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 143
Default Syntax Error '1004'

-The use of Me.Controls() was not recognized in a standard module.

true that you have to use full name of userform and controls out of the
userform module. like Userform1.Controls instead of me.controls.

"Minitman" wrote in message
...
| Hey Homey,
|
| Thanks for the reply.
|
| I tried to move the 7 subs. The use of Me.Controls() was not
| recognized in a standard module. There may have been other problems
| that had not shown up as well. I had to take the code back and call
| the macros without the variables (add a select case layer to choose
| the correct macro to run - oh well)
|
| Again, thanks for the effort
| -Minitman
| On Mon, 18 Jan 2010 09:31:13 -0500, "Homey" <none wrote:
|
| i think you need put InvCol_1 and the others in a regular module.
|
| "Minitman" wrote in message
| .. .
| | Greetings,
| |
| | I am attempting to run this macro :
| |
| | For this example x equals 1, 2 or 3. vName & vNum together is the
| | name of the originating TextBox.
| |
| | Here is the code fragment in question:
| |
| | Run "InvCol_" & x, vName, vNum
| |
| | This will run one of the three procedures known as InvCol_1, InvCol_2
| | or InvCol_3 each with the pass though arguments of vName & vNum.
| |
| | The problem is the VB error message:
| |
| | Run-time error '1004'
| | The macro 'InvCol_1' cannot be found.
| |
| | VB is calling it a macro, I'm not sure if that means anything or not.
| | The full name of the procedure is:
| |
| | Public Sub InvCol_1(vName As Variant, vNum As Variant)
| |
| | It is in the UserForm code area as is the rest of this code, It was
| | working until I changed the calling method to include a variable to
| | simplify the code.
| |
| | Can anyone see what I did wrong to mess up this code and, more
| | importantly, how do I fix it?
| |
| | Any help will be appreciated.
| |
| | -minitman
|

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Syntax Error '1004'

Hi Minitman

"It was working until I changed the calling method to include a variable to
simplify the code." This surprises me. However, if you called it with the
following method it would have worked.

Call InvCol_1(vName, vNum)

However, having said that, the only code you should have in the Userform
code area is the event code for the userform. All other code which is called
should be in a standard module and if you move the called code to a standard
module you will most likely fix the problem.

--
Regards,

OssieMac


"Minitman" wrote:

Greetings,

I am attempting to run this macro :

For this example x equals 1, 2 or 3. vName & vNum together is the
name of the originating TextBox.

Here is the code fragment in question:

Run "InvCol_" & x, vName, vNum

This will run one of the three procedures known as InvCol_1, InvCol_2
or InvCol_3 each with the pass though arguments of vName & vNum.

The problem is the VB error message:

Run-time error '1004'
The macro 'InvCol_1' cannot be found.

VB is calling it a macro, I'm not sure if that means anything or not.
The full name of the procedure is:

Public Sub InvCol_1(vName As Variant, vNum As Variant)

It is in the UserForm code area as is the rest of this code, It was
working until I changed the calling method to include a variable to
simplify the code.

Can anyone see what I did wrong to mess up this code and, more
importantly, how do I fix it?

Any help will be appreciated.

-minitman
.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 293
Default Syntax Error '1004'

Hey OssieMac,

Thanks for the reply.

Do you know of a way of starting a procedure with a split name (part
text and part variable) I got into the problem of which module the
code is sitting with the Run command {Run

On Mon, 18 Jan 2010 07:31:02 -0800, OssieMac
wrote:

Hi Minitman

"It was working until I changed the calling method to include a variable to
simplify the code." This surprises me. However, if you called it with the
following method it would have worked.

Call InvCol_1(vName, vNum)

However, having said that, the only code you should have in the Userform
code area is the event code for the userform. All other code which is called
should be in a standard module and if you move the called code to a standard
module you will most likely fix the problem.


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Syntax Error '1004'

Don't understand your question. You already have code for calling a sub in a
module and passing the arguments/parameters as follows:-

Run "InvCol_" & x, vName, vNum

The above works when InvCol_x is in a standard module.

One of your questions in a previous post on this thread referred to Me but
that was explained. Simply replace it with the Userform name.

Your quote: "I got into the problem of which module the code is sitting
with". Not sure if I understand but you should not need to specify the
module. However, having said that, you cannot have subs by the same name in
different standard modules or you cannot call them.

If this does not answer your question then perhaps you can elaborate on
your question with examples.


--
Regards,

OssieMac


"Minitman" wrote:

Hey OssieMac,

Thanks for the reply.

Do you know of a way of starting a procedure with a split name (part
text and part variable) I got into the problem of which module the
code is sitting with the Run command {Run

On Mon, 18 Jan 2010 07:31:02 -0800, OssieMac
wrote:

Hi Minitman

"It was working until I changed the calling method to include a variable to
simplify the code." This surprises me. However, if you called it with the
following method it would have worked.

Call InvCol_1(vName, vNum)

However, having said that, the only code you should have in the Userform
code area is the event code for the userform. All other code which is called
should be in a standard module and if you move the called code to a standard
module you will most likely fix the problem.


.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
run time error 1004 general odbc error excel 2003 vba Mentos Excel Programming 5 January 24th 11 02:56 PM
Error 1004 opening workbook 1004 WembleyBear Excel Programming 2 November 30th 09 01:33 PM
Error when cell A1 is not active and xlInsideVertical border formatthrowing error 1004 [email protected] Excel Programming 7 August 7th 08 08:43 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM


All times are GMT +1. The time now is 02:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"