?
Solved

Saving info to an excel file

Posted on 2003-03-31
6
Medium Priority
?
308 Views
Last Modified: 2010-04-07
Hi, I have information like the one shown below stored in a MSFlexGrid. It dislplays the data very nice, but I need to save this data to an excel file as the way it looks below. The program I have written, loops through the rows and stores each of them on top of the one before (overwrites the previous row).I think I need an array of two dimmensions to get it to look in excel the way it looks below (not sure). Any ideas? For example, if I run the program and save it to an excel file, this saved filed will show only the last row (6.). I need to show all six rows. Explain your solution please since I am still a beginner. Thank you  


1.   300        232     3644     7674564       6743    222
2.   56757     78788     43     3452       45789   783
3.   2452       4564     78445     266       457       842
4.   23445     56     746     67       5689       565
5.   56757     78788     43     3452       45789       783
6.   2452      4564     78445     266       457       842
0
Comment
Question by:caleno
6 Comments
 

Expert Comment

by:Thanbor
ID: 8242259
Here's how I do it in my project. I have the data in an array, then send it to Excel as follows:

You need a loop to increment the row in excel for each row in the grid

For X = 1 To UBound(arrGageData, 2)
For Y = 1 to 8
ApExcel.cells(X, Y).Value = arrGageData(Y, X)


Next
0
 

Accepted Solution

by:
Thanbor earned 80 total points
ID: 8242279
OOPS! I hit POST accidentally!

HERE is how its supposed to look:

For x=1 to ubound(arrGageData,2)
   For Y = 1 to 8
   ApExcel.cells(X, Y).Value = arrGageData(Y, X)
   Next
Next

The loop goes thru row and column of both the array and the spreadsheet. Note that in MY project, I switching X & Y as it goes from array to Excel.
0
 
LVL 2

Expert Comment

by:WintersVine
ID: 8242633
you don't need a multi-dimensional array, just a row and column counter. Which is what Thanbor has effectively done with an array.

a "For . . . next" loop with a varible that starts at one
you could then embed another loop to count
i.e.:
for WhatRow = 1 to RowCount
for WhatColumn = 1 to ColumnCOunt
[code that writes to Excel]
next ColumnCount
next WhatRow

of course you'll need to give the values for RowCount and ColumnCount variables.

Working with Arrays can be confusing, especially when it comes to dynamically defining an array. It may be a good way for you to figure out how arrays work; however its not necessary to use an array for this function.

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Expert Comment

by:modulo
ID: 8504679
Dear caleno

Please check:
http://www.cityofangels.com/Experts/Closing.htm

modulo

Community Support Moderator
Experts Exchange
0
 

Expert Comment

by:CleanupPing
ID: 8899815
caleno:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
LVL 77

Expert Comment

by:GrahamSkan
ID: 8985635
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
 Award points to Thanbor

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
GrahamSkan
EE Cleanup Volunteer
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

616 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