my array size is decided by the some other function. but when i tried to define the size of the array using the variable i am getting the error "Constant Expression Required"
i would like define the size of the array
Option Explicit
Sub Abcd()
Dim n_variables As Integer
n_variables = def()
MsgBox "n_variables" & n_variables
Dim abc(1 To n_variables) As Integer
End Sub
Function def()
def = 100
End Function
is there any way i can define the array size in variable format? Any one help me please.
Use the Redim statement:
Dim n_variables As Integer
n_variables = def()
MsgBox "n_variables" & n_variables
Dim abc() As Integer
Redim abc(1 To n_variables) As Integer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With