Skip to content

Instantly share code, notes, and snippets.

@nubeiro
Created October 28, 2023 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nubeiro/752b5906b5aa2332577c19850fee53bc to your computer and use it in GitHub Desktop.
Save nubeiro/752b5906b5aa2332577c19850fee53bc to your computer and use it in GitHub Desktop.
Loops selection to set negative values on red cells
Sub LoopSelection
Dim RGBarray(1 to 3)
Set oRange = ThisComponent.CurrentSelection
For i = 0 To oRange.Rows.getCount() - 1
For j = 0 To oRange.Columns.getCount() - 1
Set oCell = oRange.getCellByPosition( j, i )
CBkC = oCell.CharColor
RGBarray(1) = Red(CBkC) : RGBarray(2) = Green(CBkC) : RGBarray(3) = Blue(CBkC)
If RGBarray(1) = 255 then
if oCell.value > 0 then
dim old
old = oCell.value
oCell.value = old * -1
ENDIF
endif
Next
Next
end Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment