ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Call a procedure using a variable (https://www.excelbanter.com/excel-programming/417244-call-procedure-using-variable.html)

ranswrt

Call a procedure using a variable
 
Is there a way to call a procedure using a variable? I tried

Call reportname & "Report"

reportname is a string variable. I got a error when I tried this.
Thanks

Dave Peterson

Call a procedure using a variable
 
application.run reportname & "Report"



ranswrt wrote:

Is there a way to call a procedure using a variable? I tried

Call reportname & "Report"

reportname is a string variable. I got a error when I tried this.
Thanks


--

Dave Peterson

JLGWhiz

Call a procedure using a variable
 

Whatever you use after the word "Call" must equate to the procedure name
only, with any arguments place in parentheses.
myProcedure = DoASort
Call myProcedure(Range("A1:A100")

Unless the concatenated word is part of the name, it will throw an error.

"ranswrt" wrote:

Is there a way to call a procedure using a variable? I tried

Call reportname & "Report"

reportname is a string variable. I got a error when I tried this.
Thanks


ranswrt

Call a procedure using a variable
 
Thank You

"Dave Peterson" wrote:

application.run reportname & "Report"



ranswrt wrote:

Is there a way to call a procedure using a variable? I tried

Call reportname & "Report"

reportname is a string variable. I got a error when I tried this.
Thanks


--

Dave Peterson



All times are GMT +1. The time now is 01:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com