I have 10 records (rows) in my Excel sheet and I am taking it into array and I am not able to return it from function. I get only the last value. Below is my script.
Function fnFetchDataUsingArray()
Dim arrExcelValues()
sSheetName = Environment.Value("TestName")
sExcelWorkbookPath = "I:\ProLinkIII_TestAutomation\trunk\ProLink_TestAutomation\Datasheet\DTSheet_5700C.xlsx"
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open(sExcelWorkbookPath)
objExcel.Visible = False
Set currentWorkSheet = objExcel.ActiveWorkbook.Worksheets(sSheetName)
i = 1
x = 0
Do Until objExcel.Cells(i, 2).Value = ""
ReDim Preserve arrExcelValues(x)
arrExcelValues(x) = objExcel.Cells(i, 2).Value
i = i + 1
x = x + 1
fnFetchDataUsingArray = arrExcelValues(x-1)
Loop
objExcel.Quit
End Function
Calling the function:
arr = fnFetchDataUsingArray()
MsgBox arr
I am getting only the last value. Attached screenshot of my datasheet.
