Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Algorithm for moving to Excel Ranges
Message
From
11/02/2005 18:30:11
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
11/02/2005 18:17:59
Bill Drew
Independent Consultant
Chicago, Illinois, United States
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00986198
Message ID:
00986200
Views:
29
Instead of using column letters, you can refer to both columns and rows by number. See example in my article at http://www.utmag.com/wconnect/wc.dll?9,7,10,1562

Note that it is faster to paste an entire range, than to loop through all the cells; if speed is critical, the key consideration is the number of messages exchanged between VFP and Excel.

>I have automated Excel to paste VFP data from the clipboard. I want to drop 47 records in 5 columns at the 7th row and then paste 47 more records in 5 columns starting at the 7th row and keep doing this until I run out of data.
>
>I have a do while loop that solves the problem but there is an ugly array that I have to create in code to define the column letters for the beginining and end of each range. I can get a set of 47 records by putting an SQL command with a Between(counter,startnum,endnum) condition at the top of the loop.
>
>Could anybody take a crack at making the array in an algorithm instead of having to hard code it??
>
>Here is the beginning of the array. The trick is to go through the alphabet and then begin using the AA, AB, AC format.
>
>DECLARE col_lets(52,2)
>col_lets(1,1) = "A"
>col_lets(1,2) = "E"
>col_lets(2,1) = "F"
>col_lets(2,2) = "J"
>col_lets(3,1) = "K"
>col_lets(3,2) = "O"
>col_lets(4,1) = "P"
>col_lets(4,2) = "T"
>col_lets(5,1) = "U"
>col_lets(5,2) = "Y"
>col_lets(6,1) = "Z"
>col_lets(6,2) = "AD"
>col_lets(7,1) = "AE"
>col_lets(7,2) = "AI"
>col_lets(8,1) = "AJ"
>
>Or suggestions for a better way than hardcoding the ranges with the Range Function i.e. oExcel.range(the current top left column +"7:"+top right col+"7")
>
>Thanks.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform