Context We have data that is exported from elsewhere that we need to process on a regular basis automatically, but we've no control over how it is exported and it comes out in an unsightly and difficult to use manner. So we automated a script which takes only what we need from this first spreadsheet (oldWorksheet) and place it into a new one (newWorksheet)
We have working code, as it was auto-generated when we performed the actions manually, but we would like to try and reduce the lines of repetitive code required with some iterative loops. The pseudocode seemed promising, but we realise now that we're not sure how to go about incrementing some of these variables in the way that we want.
Question We want to have the relevant variables increase by a pre-decided amount of characters in alphabetical order every time it loops. How would we go about doing this?
var i:number = 0;
var x:string = "B";
var y:string = "D";
while (i < 100)
{
newWorksheet.getRange(x:x).copyFrom(oldWorksheet.getRange(y:y), ExcelScript.RangeCopyType.all, false, false);
// increment x by 1 (A -> B -> C etc.)
// increment y by 2 (A -> C -> E etc.)
i++;
}
Variables x and y are pertaining to the rows/columns of the Excel spreadsheets, and they will go past Z and on towards AA, AB, AC etc.
Would this be possible to do within the same process? Or will we have to keep track of how far it has gotten and then concatenate two variables together whilst it's being read by the script? i.e. something to the effect of:
while (i < 100)
{
z = columnTracker + x
// z = A + D (= AD)
newWorksheet.getRange(z:z)...
Thanks in advance!