I've read the definitions a few times over and I still don't understand the difference.
getActiveCell: Range
getCurrentCell: Range
There's this note in getActiveCell's documentation: (copy-pasted including grammatical errors)
It's preferrable to use getCurrentCell(), which the returns the current highlighted cell.
Which doesn't make it any clearer
getCurrentCell() returns the highlighted cell as seen by the dark border in the Sheets UI, whereas getActiveCell() returns the top-left cell of the selected range.
Say you have a range highlighted in a Sheet: B2:E10, for example. In the case where the you clicked on B2 and dragged down to E10:

Running the following code in the script editor:
function getCells() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1")
console.log(sheet.getActiveCell().getA1Notation())
console.log(sheet.getCurrentCell().getA1Notation())
}
You will see in the logs that both getActiveCell() and getCurrentCell() return B2.
However in the opposite scenario, where you clicked on E10 and dragged up to B2:

After running the same code, you will see that getActiveCell() still returns B2, but now getCurrentCell() returns E10.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With