Calling Worksheet SubProcs From Module

  • Thread starter Thread starter Chris Villanueva
  • Start date Start date
C

Chris Villanueva

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
 
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
 
Thanks for the info Tom. I will incorporate your advice
into my programming style. Thanks again.

Chris
 
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
 
Back
Top