PC Review


Reply
 
 
Bishop
Guest
Posts: n/a
 
      3rd Aug 2009
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?
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      3rd Aug 2009
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" <(E-Mail Removed)> wrote in message
news:0693725F-61D7-45D4-92AB-(E-Mail Removed)...
> 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?



 
Reply With Quote
 
Bishop
Guest
Posts: n/a
 
      4th Aug 2009
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.
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      4th Aug 2009
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 With Quote
 
Bony Pony
Guest
Posts: n/a
 
      4th Aug 2009
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Call a javascript when i call an aspx page with a form html not running on server Fabio Mastria Microsoft ASP .NET 4 28th Jan 2008 09:05 AM
Warning 1684 CA2214 : Microsoft.Usage : 'RandomShade..ctor(Int32, Int32, Int32, Int32, Int32)' contains a call chain that results in a call to a virtual method defined by the class. Review the following call stack for unintended consequences: steve bull Microsoft C# .NET 4 7th Jul 2005 05:54 PM
Are we new users supposed to call this number? I have auto dial on my XP in the dialer but am I required to call? Windows XP New Users 12 26th May 2005 03:47 PM
An outgoing call cannot be made since the application is dispatching an input-synchronous call Sagaert Johan Microsoft C# .NET 4 6th Apr 2005 12:12 AM
Re: Please help - How to call functions that exists in the main application. The call should be initiated from one of the components. Baavgai Microsoft C# .NET 0 4th Sep 2004 05:54 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:09 PM.