Finally I made it!
I wrote the following two functions for this purpose. Creating the following functions took me a lot of time and energy and a lot of trial and error, but it was really enjoyable.
The main GAS function with passing arguments:
function refreshRefNums(sheetName,refColumnIndex,refFirstRowIndex){
var spreadSheet = SpreadsheetApp.getActive();
var sheet = spreadSheet.getSheetByName(sheetName);
var refLastRowIndex = sheet.getLastRow();
var baseRange = sheet.getRange(refFirstRowIndex,refColumnIndex,2);
var destinationRange = sheet.getRange(refFirstRowIndex,refColumnIndex,refLastRowIndex);
baseRange.autoFill(destinationRange, SpreadsheetApp.AutoFillSeries.DEFAULT_SERIES);
}
And the function I run to do the job:
function refreshRefNumsIOUData(){
refreshRefNums("IOU Data",1,2);
}
Notes:
sheetName
is the name of the sheet that has a column for unique reference numbers strating from 1.
refColumnIndex
is the index of the column that contains reference numbers.
refFirstRowIndex
is the index of the row that reference numbers start.
refLastRowIndex
is the index of the last row containing reference numbers.