?
Solved

Saving info to an excel file

Posted on 2003-03-31
6
Medium Priority
?
295 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
[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
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 76

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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

765 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