I can call a script in R from VBA by doing
Sub CallRScript()
Dim myShell As Object
Set myShell = VBA.CreateObject("WScript.Shell")
Dim waitTillComplete As Boolean, style As Integer, path As String
waitTillComplete = True
style = 1
path = "RScript C:\R_code\Scripts\ValuationFns.R"
Call myShell.Run(path, style, waitTillComplete)
End Sub
However, the R session closes as soon as the R script is finished running. I'd like for the R session to remain open until the excel workbook is closed, an be able to run subsequent commands in the command prompt. How might I accomplish this?