Thursday, December 19, 2013

Function to write Data from Array to an Excel File

Function WriteDataToExcelFile(strOutputFilePath,strVendorMarkedForDeletion) Dim intRow Set objExcel = CreateObject("Excel.Application") objExcel.DisplayAlerts = 0 Set objWorkbook = objExcel.Workbooks.Add() Set currentWorkSheet = objExcel.ActiveWorkbook.Worksheets(1) For intRow = 1 To UBound(strVendorMarkedForDeletion) ' msgbox "intRow ::"&intRow ' msgbox "Vendor ::"&strArrayVendorMarkedForDeletion(intRow) objExcel.Cells(intRow, 1).Value = strVendorMarkedForDeletion(intRow) Next objExcel.Workbooks(1).SaveAs(strOutputFilePath) objExcel.Workbooks(1).Close objExcel.Quit Set currentWorkSheet = Nothing Set objExcel = Nothing End Function

No comments:

Post a Comment