PC Review


Reply
Thread Tools Rate Thread

Call a Private Sub using a variable

 
 
Caezar
Guest
Posts: n/a
 
      4th May 2008
The routine below does not operate as intended, as the Call method
does not recognize a variable.
Call Supported_Reports(i) does not work.

How can I change this routine to male it work?

Thanks!

Sub Format_Reports()

Dim Supported_Reports(1) As String
Dim i As Integer

Supported_Reports(0) = "CGE457"
Supported_Reports(1) = "SPE962"

For i = 0 To i = UBound(Supported_Reports)
If Not ActiveSheet.Cells.Find(Supported_Reports(i)) Is Nothing
Then Call Supported_Reports(i)
Next i

End Sub
 
Reply With Quote
 
 
 
 
Norman Jones
Guest
Posts: n/a
 
      4th May 2008
Hi Caezar,

Try using the Run method which
takes a string argument.

So replace

> Then Call Supported_Reports(i)


with

Then Application.Run Call Supported_Reports(i)

See VBA help for more information
on the Run method


---
Regards.
Norman
"Caezar" <(E-Mail Removed)> wrote in message
news:01cf13cf-d3fc-494e-b8f6-(E-Mail Removed)...
> The routine below does not operate as intended, as the Call method
> does not recognize a variable.
> Call Supported_Reports(i) does not work.
>
> How can I change this routine to male it work?
>
> Thanks!
>
> Sub Format_Reports()
>
> Dim Supported_Reports(1) As String
> Dim i As Integer
>
> Supported_Reports(0) = "CGE457"
> Supported_Reports(1) = "SPE962"
>
> For i = 0 To i = UBound(Supported_Reports)
> If Not ActiveSheet.Cells.Find(Supported_Reports(i)) Is Nothing
> Then Call Supported_Reports(i)
> Next i
>
> End Sub


 
Reply With Quote
 
Caezar
Guest
Posts: n/a
 
      4th May 2008
On May 4, 8:31 pm, "Norman Jones" <normanjo...@wherforartthou.com>
wrote:
> Hi Caezar,
>
> Try using the Run method which
> takes a string argument.
>
> So replace
>
> > Then Call Supported_Reports(i)

>
> with
>
> Then Application.Run Call Supported_Reports(i)
>
> See VBA help for more information
> on the Run method
>
> ---
> Regards.
> Norman"Caezar" <lcaza...@gmail.com> wrote in message
>
> news:01cf13cf-d3fc-494e-b8f6-(E-Mail Removed)...
>
> > The routine below does not operate as intended, as the Call method
> > does not recognize a variable.
> > Call Supported_Reports(i) does not work.

>
> > How can I change this routine to male it work?

>
> > Thanks!

>
> > Sub Format_Reports()

>
> > Dim Supported_Reports(1) As String
> > Dim i As Integer

>
> > Supported_Reports(0) = "CGE457"
> > Supported_Reports(1) = "SPE962"

>
> > For i = 0 To i = UBound(Supported_Reports)
> > If Not ActiveSheet.Cells.Find(Supported_Reports(i)) Is Nothing
> > Then Call Supported_Reports(i)
> > Next i

>
> > End Sub


Ha, thanks!
 
Reply With Quote
 
Jacques ALARDET
Guest
Posts: n/a
 
      4th May 2008
Hello
Supported_Reports is :
1. a variable in line Dim Supported_Reports(1) As String
2. a procedure in line Then Call Supported_Reports(i)

Rename first or second

J a c q u e s

"Caezar" <(E-Mail Removed)> a écrit dans le message de
news:01cf13cf-d3fc-494e-b8f6-(E-Mail Removed)...
> The routine below does not operate as intended, as the Call method
> does not recognize a variable.
> Call Supported_Reports(i) does not work.
>
> How can I change this routine to male it work?
>
> Thanks!
>
> Sub Format_Reports()
>
> Dim Supported_Reports(1) As String
> Dim i As Integer
>
> Supported_Reports(0) = "CGE457"
> Supported_Reports(1) = "SPE962"
>
> For i = 0 To i = UBound(Supported_Reports)
> If Not ActiveSheet.Cells.Find(Supported_Reports(i)) Is Nothing
> Then Call Supported_Reports(i)
> Next i
>
> End Sub


 
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 Private Sub From Different Module Richard Microsoft Excel Programming 7 9th Oct 2009 03:42 PM
Use a variable to call a variable preiously set. Richhall Windows XP General 8 19th Sep 2008 03:34 PM
How do I call a Private Sub MyCode() from another place ? Isis Microsoft Access Getting Started 4 19th Jun 2008 10:55 AM
How to call a private sub() in another module =?Utf-8?B?SkBZ?= Microsoft Excel Programming 4 13th Jul 2007 08:08 PM
IF Statements-call private sub =?Utf-8?B?Q3JpbXNvblBsYWd1ZTI5?= Microsoft Excel Worksheet Functions 0 11th May 2006 04:54 PM


Features
 

Advertising
 

Newsgroups
 


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