Export array values to Excel
Hi,
I'm trying to write the values of a single dimension array to a new Excel worksheet:
Code:
Sub Problem()
Dim arrTest() As String
arrTest = Split("A|B|C|D", "|")
WriteToExcel arrTest
End Sub
Sub WriteToExcel(ByVal arrPassed)
Dim o As Object
Set o = CreateObject("excel.application")
o.Visible = True
o.Workbooks.Add
o.sheets("sheet1").Range("A1:A" & UBound(arrPassed) + 1).Value = arrPassed
End Sub
The result I get is "A" in each cell. How do I revise this code so that "A" is in Cell A1, "B" is in Cell A2, etc.
Is there a better way to write an array to Excel? Thanks.