#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Call Sub

I'm trying to call a sub routine in another spreadsheet but I keep getting a
compile error "sub or function not defined." I have the following code:

....
If Not mybook Is Nothing Then

'Need to do the following:
'if lazy eye hasn't been run in directorcopy then run it
With mybook.Worksheets("DirectorCopy")
If .Cells(1, 1) = "" Then
Call DirectorFormat
DCLastRow = .Range("A" & Rows.Count).End(xlUp).Row
'Determine how many rows in directorcopy
Else
DCLastRow = .Range("A" & Rows.Count).End(xlUp).Row
End If
....

Call DirectorFormat is giving me the error. I've also tried Call
DirectorCopyFormat.DirectorFormat (DirectorCopyFormat is the module
Directorformat sits in) but that gives me the same error. What am I doing
wrong?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 915
Default Call Sub

Bishop wrote:
I'm trying to call a sub routine in another spreadsheet but I keep getting a
compile error "sub or function not defined." I have the following code:

...
If Not mybook Is Nothing Then

'Need to do the following:
'if lazy eye hasn't been run in directorcopy then run it
With mybook.Worksheets("DirectorCopy")
If .Cells(1, 1) = "" Then
Call DirectorFormat
DCLastRow = .Range("A" & Rows.Count).End(xlUp).Row
'Determine how many rows in directorcopy
Else
DCLastRow = .Range("A" & Rows.Count).End(xlUp).Row
End If
...

Call DirectorFormat is giving me the error. I've also tried Call
DirectorCopyFormat.DirectorFormat (DirectorCopyFormat is the module
Directorformat sits in) but that gives me the same error. What am I doing
wrong?


Is DirectorFormat declared as Private? If so, it cannot be called from
outside the module it resides in.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Call Sub

If you call from a different workbook, then you have to specify the Projectt
name (Workbook in Excel) and the module where the macro resides.


"Bishop" wrote in message
...
I'm trying to call a sub routine in another spreadsheet but I keep getting
a
compile error "sub or function not defined." I have the following code:

...
If Not mybook Is Nothing Then

'Need to do the following:
'if lazy eye hasn't been run in directorcopy then run
it
With mybook.Worksheets("DirectorCopy")
If .Cells(1, 1) = "" Then
Call DirectorFormat
DCLastRow = .Range("A" &
Rows.Count).End(xlUp).Row
'Determine how many rows in directorcopy
Else
DCLastRow = .Range("A" &
Rows.Count).End(xlUp).Row
End If
...

Call DirectorFormat is giving me the error. I've also tried Call
DirectorCopyFormat.DirectorFormat (DirectorCopyFormat is the module
Directorformat sits in) but that gives me the same error. What am I doing
wrong?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Call Sub

That's a good question. I forgot to check for that. However, it is not
declared as private.

"smartin" wrote:

Bishop wrote:
I'm trying to call a sub routine in another spreadsheet but I keep getting a
compile error "sub or function not defined." I have the following code:

...
If Not mybook Is Nothing Then

'Need to do the following:
'if lazy eye hasn't been run in directorcopy then run it
With mybook.Worksheets("DirectorCopy")
If .Cells(1, 1) = "" Then
Call DirectorFormat
DCLastRow = .Range("A" & Rows.Count).End(xlUp).Row
'Determine how many rows in directorcopy
Else
DCLastRow = .Range("A" & Rows.Count).End(xlUp).Row
End If
...

Call DirectorFormat is giving me the error. I've also tried Call
DirectorCopyFormat.DirectorFormat (DirectorCopyFormat is the module
Directorformat sits in) but that gives me the same error. What am I doing
wrong?


Is DirectorFormat declared as Private? If so, it cannot be called from
outside the module it resides in.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Call Sub

And you don't have:
Option Private Module
at the top of that module, right?????


Bishop wrote:

That's a good question. I forgot to check for that. However, it is not
declared as private.

"smartin" wrote:

Bishop wrote:
I'm trying to call a sub routine in another spreadsheet but I keep getting a
compile error "sub or function not defined." I have the following code:

...
If Not mybook Is Nothing Then

'Need to do the following:
'if lazy eye hasn't been run in directorcopy then run it
With mybook.Worksheets("DirectorCopy")
If .Cells(1, 1) = "" Then
Call DirectorFormat
DCLastRow = .Range("A" & Rows.Count).End(xlUp).Row
'Determine how many rows in directorcopy
Else
DCLastRow = .Range("A" & Rows.Count).End(xlUp).Row
End If
...

Call DirectorFormat is giving me the error. I've also tried Call
DirectorCopyFormat.DirectorFormat (DirectorCopyFormat is the module
Directorformat sits in) but that gives me the same error. What am I doing
wrong?


Is DirectorFormat declared as Private? If so, it cannot be called from
outside the module it resides in.


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Call Sub

I find that application.run("module") works in all cases or if you want to
pass variables

sdoit = application.run("module",var1,var2 etc)

"Dave Peterson" wrote:

And you don't have:
Option Private Module
at the top of that module, right?????


Bishop wrote:

That's a good question. I forgot to check for that. However, it is not
declared as private.

"smartin" wrote:

Bishop wrote:
I'm trying to call a sub routine in another spreadsheet but I keep getting a
compile error "sub or function not defined." I have the following code:

...
If Not mybook Is Nothing Then

'Need to do the following:
'if lazy eye hasn't been run in directorcopy then run it
With mybook.Worksheets("DirectorCopy")
If .Cells(1, 1) = "" Then
Call DirectorFormat
DCLastRow = .Range("A" & Rows.Count).End(xlUp).Row
'Determine how many rows in directorcopy
Else
DCLastRow = .Range("A" & Rows.Count).End(xlUp).Row
End If
...

Call DirectorFormat is giving me the error. I've also tried Call
DirectorCopyFormat.DirectorFormat (DirectorCopyFormat is the module
Directorformat sits in) but that gives me the same error. What am I doing
wrong?

Is DirectorFormat declared as Private? If so, it cannot be called from
outside the module it resides in.


--

Dave Peterson

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
how to call a vb.net dll from VBA Brian Murphy Excel Programming 2 March 6th 09 04:31 AM
Call Center Management: How to calculate 'cost per call' Denniso6 Excel Discussion (Misc queries) 2 June 25th 06 05:01 PM
call sub mike allen[_2_] Excel Programming 3 October 15th 04 04:54 PM
How do you call one Sub from another Sub ? lothario[_30_] Excel Programming 2 October 17th 03 01:47 PM
call sub Claudia Dell'Era[_2_] Excel Programming 3 October 3rd 03 01:31 PM


All times are GMT +1. The time now is 01:10 PM.

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

About Us

"It's about Microsoft Excel"