Here’s the sequence I’m having problems with:
for BRowNumber = BEndRow to 4 step -1
oBufferCell = BufferSheet.getCellByPosition(4, BRowNumber) Rem the "4" refers to the column number, This should be correct (ie the 5th column, "days left") oBufferACell= BufferSheet.getCellByPosition(5, BRowNumber) Rem the "5" refers to the column number, This should be correct (ie the 6h column, "Account") PoundCell = BufferSheet.getCellByPosition(8,BRowNumber) rem Cell containing amount in pounds PoundAmount = PoundCell.value DollarCell = BufferSheet.getCellByPosition(7,BRowNumber) rem Cell containing amount in dollars DollarAmount = DollarCell.value if oBufferCell.value = Matured Then BufferSheet.rows.removeByIndex(BRowNumber, 1) Elseif oBufferACell.value= IBKRM Then DestCell = BufferSheet.getCellByPosition(12,BRowNumber) DestCell2=BufferSheet.getCellByPosition(13,BrowNumber) DestCell.setValue(DollarAmount) DestCell2.setValue(PoundAmount) Elseif oBufferACell.value= iWeb Then DestCell = BufferSheet.getCellByPosition(14,BRowNumber) DestCell2=BufferSheet.getCellByPosition(15,BrowNumber) DestCell.setValue(DollarAmount) DestCell2.setValue(PoundAmount) Elseif oBufferACell.value= NottsBS Then DestCell = BufferSheet.getCellByPosition(16,BRowNumber) DestCell2=BufferSheet.getCellByPosition(17,BrowNumber) DestCell.setValue(DollarAmount) DestCell2.setValue(PoundAmount) Elseif oBufferACell.value= IBKR Then DestCell = BufferSheet.getCellByPosition(10,BRowNumber) DestCell2=BufferSheet.getCellByPosition(11,BrowNumber) DestCell.setValue(DollarAmount) DestCell2.setValue(PoundAmount)
end if
next BRowNumber
It loops through a Calc sheet row by row. If the cell in the 5th column of the row says Matured, it deletes that row. This part works, even though the Watch window says the cell to which this value is assigned (oBufferCell.value) shows as “out of scope”.
If the above test is negative (the 5th cell is not “Matured”), it is supposed to run through a series of Elseifs and place values in columns to the right. Which column it places these values in depends on the string in the 6th column of the row.
On the test Elseif oBufferACell.value=IBKRM, the first in the sequence of Elseifs, the Watch window says that oBufferACell,value is “out of scope”.
And whatever is actually in BRowNumber column 6, the code always puts in numbers in the same columns to the right, columns M and N (corresponding to index numbers 12 and 13. It then goes to Endif and Next BRowNumber.
I cannot figure out why this is happening. Any help appreciated.