If I have an excel function such as:
=my_function(A1:C4)
and I want to call this from VBA like:
Dim t as variant
t = Application.Run("my_function",X)
What is the simplest way for X to represent A1:C4?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your range has to come from a worksheet, so if you define that range first and then pass it to the function in your other workbook (I assume that’s what you want to do since you wouldn’t use Application.Run otherwise). So the following code will do the trick:
And the function in the workbook “MyOtherWorkbook.xls”: