Information générale
Catégorie:
COM/DCOM et OLE Automation
Titre:
Algorithm for moving to Excel Ranges
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.
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement