Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a .xls file from an array

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
First of all hello and thanks for replying.
So, once the array of data i register is OK, how can I copy them directly in a excel file format. Are there some spécial control that should be used or so?
 
Sub main()
Dim VarI() As Double
ReDim VarI(1000)
For i = 0 To 1000
VarI(i) = Rnd * 888888
Next i
Call CrtExcelBook(VarI(), 1000)
End Sub

Sub CrtExcelBook(MyArr, MACount)
Dim lk As Long, i As Integer
Dim xlApp, xlBook, xlExcel As Object

Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlExcel = xlBook.Worksheets(1)
xlExcel.Range("A1").Select

For i = 0 To MACount - 1
xlApp.ActiveCell.Offset(i, 0) = MyArr(i)
Next i

xlApp.Application.Visible = True
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top