?
Solved

importing arrays into excel

Posted on 2003-03-23
5
Medium Priority
?
152 Views
Last Modified: 2010-05-01
This Topic has to do with easy points.

I have created several arrays of vaiable dimension, ie. (1 to 10000, 1 to 6).
I wish to open a new excel spreadsheet and import the arrays into (1 to 6) columns in the spreadsheet, activated by a button on a form.

That is all.....

All I want is a resource with some sample source code.

Thanks
RDXBREWER
0
Comment
Question by:RDXBrewer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 27

Expert Comment

by:Dabas
ID: 8192438
This worked for me:

Option Explicit
Dim ar(1 To 100, 1 To 6) As String 'Change for real purposes.
Dim i As Integer
Dim j As Integer
Dim xl As New Excel.Application
Dim wb As Excel.Workbook
Dim ws As Excel.Worksheet

Private Sub Command1_Click()


For i = 1 To UBound(ar, 1)
    For j = 1 To UBound(ar, 2)
        ws.Cells(i, j) = ar(i, j)
    Next
Next
xl.Visible = True
End Sub

Private Sub Form_Load()
Set wb = xl.Workbooks.Add
Set ws = wb.Worksheets(1)

'Create random numbers into array for testing purposes
    For i = 1 To UBound(ar, 1)
        For j = 1 To UBound(ar, 2)
            ar(i, j) = Int(Rnd() * 100)
        Next
    Next
End Sub

I hope this points you in the right direction

Dabas
0
 
LVL 27

Expert Comment

by:Dabas
ID: 8192444
This worked for me:

Option Explicit
Dim ar(1 To 100, 1 To 6) As String 'Change for real purposes.
Dim i As Integer
Dim j As Integer
Dim xl As New Excel.Application
Dim wb As Excel.Workbook
Dim ws As Excel.Worksheet

Private Sub Command1_Click()


For i = 1 To UBound(ar, 1)
    For j = 1 To UBound(ar, 2)
        ws.Cells(i, j) = ar(i, j)
    Next
Next
xl.Visible = True
End Sub

Private Sub Form_Load()
Set wb = xl.Workbooks.Add
Set ws = wb.Worksheets(1)

'Create random numbers into array for testing purposes
    For i = 1 To UBound(ar, 1)
        For j = 1 To UBound(ar, 2)
            ar(i, j) = Int(Rnd() * 100)
        Next
    Next
End Sub

I hope this points you in the right direction

Dabas
0
 

Author Comment

by:RDXBrewer
ID: 8204311
I must not have something set right.

I'm getting an error on:
Dim xl As New Excel.Application

as a user defined type, i.e. not recognizing it and I know I have office installed
0
 
LVL 27

Accepted Solution

by:
Dabas earned 1000 total points
ID: 8204647
You have to go to Tools -> References and tick Microsoft Excel
0
 

Expert Comment

by:CleanupPing
ID: 8531773
Hi RDXBrewer,
This old question (QID 20560404) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question