jcd
10-01-2001, 08:54 AM
does anyone know how to save the entire contents of an excel file into an array withou reading the file line by line
regards
jcd
regards
jcd
excel file => arrayjcd 10-01-2001, 08:54 AM does anyone know how to save the entire contents of an excel file into an array withou reading the file line by line regards jcd orufet 10-01-2001, 08:57 AM Why don't you want to read it line by line? I think that's the easiest way....Unless you're doing this in VBA, then there might be a better way to do it... "I do not agree with a word you say, but I will defend to the death your right to say it" - Voltaire jcd 10-01-2001, 08:59 AM line by line is slow...the HD is constantly spinning and as you know mechanical is relatively slow...if I could put it in an array all at once I think it would speed things up...maybe it wouldnt???...any suggestions would be appreciated. regards jcd diver 10-01-2001, 06:11 PM I think where the confusion here is, that you are saying an "entire file". Excel spreadsheets can be enormous. Do you have a particular "range" of data that you are trying to pull? If so, then there is a very quick way to do this. D Timbo 10-01-2001, 06:27 PM loop each worksheet in the workbook and assign the Sheet(x).UsedRange.Value (or .Formula) property to a variant. You will get an array of the cells contents. However I assume you will still have to output the array contents somehow, and if you need to retrieve paticuar data items, you will be faced withthe same problem (in reverse). You may want to consider returning a recordset object using SQL as discussed here (http://www.visualbasicforum.com/bbs/showthreaded.php?Cat=&Board=vba&Number=50743&Search=true&Forum=CatSearch-1&Words=SQL%20Excel&Match=And&Searchpage=0&Limit=25&Old=1month&Main=48863). "He who dares my son!.. He who dares.." - Del-Boy Trotter jcd 10-02-2001, 06:51 AM Timbo I didnt even think that could be done...amazing...I only new that you either had to fire up an excel application or you had to use file input and go line by line...I am going to test it out thanks alot... regards jcd Ad1 10-02-2001, 08:11 AM thats the kind of thing I need, but how would you get the seperate values out ie if you had usedrange.value=(1 to 8, 1 to 1) how could you get those 4 values into seperate variables to set up a nested for loop like <pre><font color=blue>For</font color=blue> X = intColStart <font color=blue>To</font color=blue> intColEnd <font color=blue>For</font color=blue> Y = intRowStart <font color=blue>To</font color=blue> intRowEnd strReplace = xlSheet.Worksheets(1).Range(Chr(Y + 64) & X).Value txtHTML.Text = Replace(txtHTML.Text, "ID=MHDDEExcel><", ID="MHDDEExcel>" & strReplace & "<", , 1, vbTextCompare) <font color=blue>Next</font color=blue> Y <font color=blue>Next</font color=blue> X </pre> I tried to find the values in my watch window but it crashes my system when I try to access it Timbo 10-02-2001, 06:38 PM try using your Locals window (View menu), and use the '.Cells(X,Y).Value' method instead.. "He who dares my son!.. He who dares.." - Del-Boy Trotter Ad1 10-03-2001, 06:05 AM the locals window is still crashing out my system when I try to expand "cells", anyway I got the values I wanted by putting <pre>var = xlBook.Worksheets(1).UsedRange.Value intRowStart = <font color=blue>LBound</font color=blue>(var,1) intColStart = <font color=blue>LBound</font color=blue>(var,2) intRowEnd = <font color=blue>UBound</font color=blue>(var,1) intColEnd = <font color=blue>UBound</font color=blue>(var,2) </pre> cheers for the tip |
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum