Building custom solutions that extend, automate, and integrate Microsoft 365 apps.
Hey Mehdi Rajabali I guess you can use dynamic arrays: ex- below for you
' Assuming you have a form where the user provides the variable names Sub CreateDynamicVariables() Dim userInput As String Dim dynamicVariables() As Variant Dim i As Integer ' Get user input (variable name) userInput = InputBox("Enter a variable name:") ' Check if the user entered a variable name If userInput <> "" Then ' Check if the variable already exists For i = LBound(dynamicVariables) To UBound(dynamicVariables) If dynamicVariables(i) = userInput Then MsgBox "Variable already exists!" Exit Sub End If Next i ' If the variable doesn't exist, add it to the array ReDim Preserve dynamicVariables(0 To UBound(dynamicVariables) + 1) dynamicVariables(UBound(dynamicVariables)) = userInput ' Now you have a dynamic array of variable names ' You can use this array for further processing or store values in corresponding variables MsgBox "Variable added: " & userInput Else MsgBox "No variable name entered!" End If End Sub
If this helps kindly accept the answer thanks much.