Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Algorithm for moving to Excel Ranges
Message
From
11/02/2005 18:17:59
Bill Drew
Independent Consultant
Chicago, Illinois, United States
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Algorithm for moving to Excel Ranges
Miscellaneous
Thread ID:
00986198
Message ID:
00986198
Views:
52
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.
Next
Reply
Map
View

Click here to load this message in the networking platform