Thursday, 15 September 2016

VBScript: Function Returning Array



Function Getdata()

Dim a()
strt = "sumit"
strt2 = "raut"
a = Array(strt, strt2)

Getdata = a()


End Function

Sub main()


Dim oExcel, oWB, oSheet, setVal
Set oExcel = CreateObject("Excel.Application")
Set oWB = oExcel.Workbooks.Open("D:\Macrowork\Call from Sub.xlsx")
Set oSheet = oWB.WorkSheets("data")
oExcel.Visible = True
Dim Arr1()

rowcount = oSheet.usedrange.rows.Count

For r = 2 To rowcount Step 1

Arr1 = Getdata
oSheet.cells(r, 4) = Arr1(0)
oSheet.cells(r, 5) = Arr1(1)

Next

oWB.Save
Set oExcel = Nothing

End Sub


No comments:

Post a Comment

Spring Boot : Exception Handler 14