Can I create a number of variables during run time based on a numeric value fetched from excel. Say, I fetch 5 from excel and create 5 variables and assign values to them fetched from excel. I ve tried a few ways to do it, but I think Im missing something.
Dim MyVarName(2)'No. of variables fetched from excel
MyVarName(0)="Name"'Names of the variable to be created fetched from excel
MyVarName(1)="Name1"'Names of the variable to be created fetched from excel
Max = 1
For iCount = 0 To Max
''Create variable here in each iteration
i dont know, how your Excel sheet looks... if you want to fetch the value using column header then , use the combination of for loop and select case statement to read values from the excel.i attached the sample excel file(image) to read value from the file use the below code.
RowCount = DataTable.GetRowCount
For i= 1 To RowCount
I would suggest using a dictionary object, instead.
Declare a dictionary, cycle through the data sheet, add each value to the dictionary. If you need to have all the values reset for each iteration, you can use the RemoveAll method on the dictionary before adding the new values.