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
Bookmarks