# How to use parameters in Excel macros (VBA)?

**URL:** <https://community.automationedge.com/t/how-to-use-parameters-in-excel-macros-vba/17774>\
**Category:** Process Studio\
**Created:** [April 11, 2026, 12:05pm UTC](https://community.automationedge.com/t/how-to-use-parameters-in-excel-macros-vba/17774 "2026-04-11T12:05:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ankit\_99](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@Ankit\_99](https://community.automationedge.com/u/Ankit_99)\
**Post date:** [April 11, 2026, 12:05pm UTC](https://community.automationedge.com/t/how-to-use-parameters-in-excel-macros-vba/17774/1 "2026-04-11T12:05:09Z")

</div>

Hi Team,

I am using Excel macros in VBA and currently have many hardcoded values (file path, sheet name, etc.).

How can I use parameters to pass values dynamically in a macro instead of hardcoding?

Thank You!

---

<div class="post-metadata">

**Author:** ![Pushkraj](https://avatars.discourse-cdn.com/v4/letter/p/b38774/32.png) [@Pushkraj](https://community.automationedge.com/u/Pushkraj)\
**Post date:** [April 11, 2026, 12:14pm UTC](https://community.automationedge.com/t/how-to-use-parameters-in-excel-macros-vba/17774/2 "2026-04-11T12:14:13Z")

</div>

1. Define Workflow Parameters  
First, you must create the parameters within the Workflow Properties of Process Studio.

Go to the Parameters tab in your workflow properties.

Define names such as filename, filePath, sheetName, or macroName.

Assign them default values or let them be populated dynamically at runtime.

1. Access Parameters in “Execute VB Script”  
Inside your Execute VB Script step, you can retrieve these workflow parameters using the following syntax:

VBScript  
’ Declare variables to hold the parameter values  
Dim filePath, sheetName, macroName

’ Retrieve values from AutomationEdge Workflow Parameters  
filePath = “${filePath}”  
sheetName = “${sheetName}”  
macroName = “${macroName}”

’ Now use these variables in your Excel automation logic  
’ Example:  
’ objExcel.Workbooks.Open(filePath)  
3. Pass Parameters to the Macro  
If you are calling a specific sub-routine within your Excel file that requires arguments, use the Application.Run method:

VBScript  
’ Calling a macro named “ProcessData” and passing the sheet name as an argument  
objExcel.Run “ProcessData”, sheetName
