ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Calling Worksheet SubProcs From Module (https://www.excelbanter.com/excel-programming/299714-calling-worksheet-subprocs-module.html)

Chris Villanueva

Calling Worksheet SubProcs From Module
 
Good Afternoon.

I have 5 Public Subs() in 5 different worksheets. I have
the following code in Module 2 that I would like to use
to call all 5 subs. But I keep getting a "sub or
function not defined" error:

CODE:
Public Sub SendDataToReport()
Call SendToWord
Call SendToWord2
Call SendToWord3
Call SendToWord4
Call SendToWord5
End Sub
/CODE:

Why does this happen? How can I call all five subs from
within module 2? All worksheet subs are public not
private.

Suggestions?

Thanks for the help

chris


Tom Ogilvy

Calling Worksheet SubProcs From Module
 
Best would not to have them in the worksheets - reserve worksheet code for
events associated with the worksheet.

If you wish to keep them there, preface them with the sheet code name

CODE:
Public Sub SendDataToReport()
Call Sheet1!SendToWord
Call Sheet2!SendToWord2
Call Sheet3!SendToWord3
Call Sheet4!SendToWord4
Call Sheet5!SendToWord5
End Sub

--
Regards,
Tom Ogilvy



"Chris Villanueva" wrote in message
...
Good Afternoon.

I have 5 Public Subs() in 5 different worksheets. I have
the following code in Module 2 that I would like to use
to call all 5 subs. But I keep getting a "sub or
function not defined" error:

CODE:
Public Sub SendDataToReport()
Call SendToWord
Call SendToWord2
Call SendToWord3
Call SendToWord4
Call SendToWord5
End Sub
/CODE:

Why does this happen? How can I call all five subs from
within module 2? All worksheet subs are public not
private.

Suggestions?

Thanks for the help

chris




ChrisV[_3_]

Calling Worksheet SubProcs From Module
 
Thanks for the info Tom. I will incorporate your advice
into my programming style. Thanks again.

Chris

-----Original Message-----
Best would not to have them in the worksheets - reserve

worksheet code for
events associated with the worksheet.

If you wish to keep them there, preface them with the

sheet code name

CODE:
Public Sub SendDataToReport()
Call Sheet1!SendToWord
Call Sheet2!SendToWord2
Call Sheet3!SendToWord3
Call Sheet4!SendToWord4
Call Sheet5!SendToWord5
End Sub

--
Regards,
Tom Ogilvy



"Chris Villanueva" wrote in message
...
Good Afternoon.

I have 5 Public Subs() in 5 different worksheets. I

have
the following code in Module 2 that I would like to use
to call all 5 subs. But I keep getting a "sub or
function not defined" error:

CODE:
Public Sub SendDataToReport()
Call SendToWord
Call SendToWord2
Call SendToWord3
Call SendToWord4
Call SendToWord5
End Sub
/CODE:

Why does this happen? How can I call all five subs

from
within module 2? All worksheet subs are public not
private.

Suggestions?

Thanks for the help

chris



.


Tom Ogilvy

Calling Worksheet SubProcs From Module
 
Actually, the ! should be a period - my mistake.

Public Sub SendDataToReport()
Call Sheet1.SendToWord
Call Sheet2.SendToWord2
Call Sheet3.SendToWord3
Call Sheet4.SendToWord4
Call Sheet5.SendToWord5
End Sub

--
Regards,
Tom Ogilvy


"ChrisV" wrote in message
...
Thanks for the info Tom. I will incorporate your advice
into my programming style. Thanks again.

Chris

-----Original Message-----
Best would not to have them in the worksheets - reserve

worksheet code for
events associated with the worksheet.

If you wish to keep them there, preface them with the

sheet code name

CODE:
Public Sub SendDataToReport()
Call Sheet1!SendToWord
Call Sheet2!SendToWord2
Call Sheet3!SendToWord3
Call Sheet4!SendToWord4
Call Sheet5!SendToWord5
End Sub

--
Regards,
Tom Ogilvy



"Chris Villanueva" wrote in message
...
Good Afternoon.

I have 5 Public Subs() in 5 different worksheets. I

have
the following code in Module 2 that I would like to use
to call all 5 subs. But I keep getting a "sub or
function not defined" error:

CODE:
Public Sub SendDataToReport()
Call SendToWord
Call SendToWord2
Call SendToWord3
Call SendToWord4
Call SendToWord5
End Sub
/CODE:

Why does this happen? How can I call all five subs

from
within module 2? All worksheet subs are public not
private.

Suggestions?

Thanks for the help

chris



.





All times are GMT +1. The time now is 11:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com