Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > VBA Passing Multipe Arguements in Function


Reply
 
Thread Tools Display Modes
  #1  
Old 06-29-2012, 05:35 AM
DaveyB DaveyB is offline
Junior Contributor
 
Join Date: Jan 2004
Posts: 249
Unhappy VBA Passing Multipe Arguements in Function


Hi All,

I am using a 3rd Party function called RunRCall (which is part of the R statconn package) this requires two arguements (RProc As String, ParamArray args() As Variant) to be passed to it.

When I pass the arguements like this:
Code:
RunRCall(strQuery,  CVar(Range("Example!$A$9:$A$18")), CVar(Range("Example!$B$9:$B$18")) ', CVar(Range("Example!$C$9:$C$18"))
It works perfectly!

What I want to do is replace this bit:
Code:
CVar(Range("Example!$A$9:$A$18")), CVar(Range("Example!$B$9:$B$18")) ', CVar(Range("Example!$C$9:$C$18")
With dynamically created code so that if I wanted to pass it 3, 5, 7 Ranges it would work.

However I do not know how to do this apart from writing 100's of lines of codes like this:

Code:
If 3 columns selected then(
RunRCall(strQuery,  CVar(Range("Example!$A$9:$A$18")), CVar(Range("Example!$B$9:$B$18")) ', CVar(Range("Example!$C$9:$C$18"))
)
else if 4 columns selected then (
RunRCall(strQuery,  CVar(Range("Example!$A$9:$A$18")), CVar(Range("Example!$B$9:$B$18")) ', CVar(Range("Example!$C$9:$C$18"), CVar(Range("Example!$D$9:$D$18"))
)
else if 5 columns selected then (
RunRCall(strQuery,  CVar(Range("Example!$A$9:$A$18")), CVar(Range("Example!$B$9:$B$18")) ', CVar(Range("Example!$C$9:$C$18"), CVar(Range("Example!$D$9:$D$18")"), CVar(Range("Example!$E$9:$E$18"))
)

... and so on to 100


Does anyone else know a better way?
__________________
There are 10 sort of people that exist in this world, The ones who understand binary and the rest

Last edited by DaveyB; 06-29-2012 at 05:44 AM.
Reply With Quote
  #2  
Old 06-29-2012, 12:27 PM
ZKat ZKat is offline
Centurion
 
Join Date: May 2006
Posts: 132
Default

Hi,

I would reach out to your 3rd party vendor; they are the experts with their product and should be able to find you a solution.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->