Created
October 28, 2023 17:22
-
-
Save nubeiro/752b5906b5aa2332577c19850fee53bc to your computer and use it in GitHub Desktop.
Loops selection to set negative values on red cells
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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