+ Reply to Thread
Results 1 to 2 of 2

Function to handle an unlimited amount of named variables and ranges

  1. #1
    Registered User
    Join Date
    10-31-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    41

    Function to handle an unlimited amount of named variables and ranges

    I am trying to write a function where I input as many variables and ranges as I want and it will send it to R using RExcel. Currently I can just do a single var entry at a time using the function RPut such as =RPut("X1",A2:A16) which puts in the A2:A16 range into R as the variable X1.

    Ideally I want to write something such as VariableToR("x1", A2:A16,"x2", B2:B16,...) for all the variables I might be using at a time. Any thought on how I can write a function using a loop to do this?

    I am guessing something like:

    Function VariableToR(ParamArray Var() As String, ParamArray Ranges() As Range)
    Dim i As Integer
    For i = LBound(Var) To UBound(Var)
    RPut("Var(i)",Range(i))
    Next
    End Function
    Last edited by Boo123; 07-06-2015 at 02:54 PM.

  2. #2
    Forum Contributor
    Join Date
    07-07-2014
    Location
    ericbartha.com
    MS-Off Ver
    2016 Professional
    Posts
    126

    Re: Function to handle an unlimited amount of named variables and ranges

    Sounds like you need an Array. Try the Array() function, eg
    Please Login or Register  to view this content.
    and see if it works for you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 5
    Last Post: 12-17-2014, 12:23 AM
  2. Function to sort multiple named ranges using variables
    By Mad_Doktor in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-28-2013, 02:53 PM
  3. Using Variables when defining named ranges
    By jerryliang2k in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-23-2008, 05:01 PM
  4. [SOLVED] Named ranges and variables
    By Mats Samson in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-19-2005, 08:05 PM
  5. [SOLVED] Named ranges and variables
    By Mats Samson in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-18-2005, 11:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1