I wrote this code on Sheet Events–>Double Click
Function onDblClick(oEvent As Variant) As Boolean
Const RANGE_TO_COLORIZE = "B2:U37" ' Set a range address that will respond to double clicks '
onDblClick = False
If oEvent.getSpreadsheet().getCellRangeByName(RANGE_TO_COLORIZE).queryIntersection(oEvent.getRangeAddress()).getCount() Then
If oEvent.getSpreadsheet().getCellRangeByName("J7:U7").queryIntersection(oEvent.getRangeAddress()).getCount() Then
Exit Function
Elseif oEvent.getSpreadsheet().getCellRangeByName("k18:u18").queryIntersection(oEvent.getRangeAddress()).getCount() Then
Exit Function
Elseif oEvent.getSpreadsheet().getCellRangeByName("c2:u2").queryIntersection(oEvent.getRangeAddress()).getCount() Then
Exit Function
End if
onDblClick = True
If oEvent.CellBackColor = -1 then
oEvent.CellBackColor = rgb(255,255,0)
Exit Function
Elseif oEvent.CellBackColor = rgb(255,255,0) then
oEvent.CellBackColor = -1
Exit Function
EndIf
EndIf
End Function
My current code changes background cell color to yellow when double clicked and then changes it back to white when double clicked again.
A error occurs when a figure (not a cell) is double clicked.
Does anyone have a idea why it happens?
this is my calc (a sticker album)