Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Create loop in range cell for count

Hello,

i need to count the cell with the same background color in a range of cell. The range is define as :

oRange = sheet.getCellRangeByPosition(7, nRiga+startIndex, 8, nRiga+stopIndex)

and in this range i use a condition

oRed4Condition(0).Name = "Operator" oRed4Condition(0).Value = com.sun.star.sheet.ConditionOperator.NOT_BETWEEN oRed4Condition(1).Name = "Formula1" oRed4Condition(1).Value = climit oRed4Condition(2).Name = "Formula2" oRed4Condition(2).Value = "-" + climit oRed4Condition(3).Name = "StyleName" oRed4Condition(3).Value = "Senza nome1"

i want to count the cell that are true for this condition. i'm tring with

for each c In oRange.CellFormatRanges
    if (c.CellBackColor =   oRed4Condition(3).Value) then
        checkResult = checkResult + 1
    endif
next c

but oRange.CellFormatRanges is not correct... how i can loop all cell and check this condition?

Thanks Daniele

click to hide/show revision 2
None

updated 2017-12-11 17:21:26 +0200

Lupp gravatar image

Create loop in range cell for count

Hello,

i need to count the cell with the same background color in a range of cell. The range is define as :

oRange = sheet.getCellRangeByPosition(7, nRiga+startIndex, 8, nRiga+stopIndex)

nRiga+stopIndex)

and in this range i use a condition

oRed4Condition(0).Name = "Operator"
 oRed4Condition(0).Value = com.sun.star.sheet.ConditionOperator.NOT_BETWEEN
 oRed4Condition(1).Name = "Formula1"
 oRed4Condition(1).Value = climit
 oRed4Condition(2).Name = "Formula2"
 oRed4Condition(2).Value = "-" + climit
 oRed4Condition(3).Name = "StyleName"
 oRed4Condition(3).Value = "Senza nome1"

i nome1"

I want to count the cell cells that are true for this condition. i'm tring with

 for each c In oRange.CellFormatRanges
     if (c.CellBackColor =    oRed4Condition(3).Value) then
        checkResult = checkResult + 1
     endif
 next c
c

but oRange.CellFormatRanges is not correct... how i can loop all cell and check this condition?

Thanks DanieleDaniele
(Edited for better readability by @Lupp )

click to hide/show revision 3
None

updated 2017-12-11 17:22:34 +0200

Lupp gravatar image

Create loop in range cell for count

Hello,

i need to count the cell with the same background color in a range of cell. The range is define as :

oRange = sheet.getCellRangeByPosition(7, nRiga+startIndex, 8, nRiga+stopIndex)

and in this range i use a condition

oRed4Condition(0).Name = "Operator"
oRed4Condition(0).Value = com.sun.star.sheet.ConditionOperator.NOT_BETWEEN
oRed4Condition(1).Name = "Formula1"
oRed4Condition(1).Value = climit
oRed4Condition(2).Name = "Formula2"
oRed4Condition(2).Value = "-" + climit
oRed4Condition(3).Name = "StyleName"
oRed4Condition(3).Value = "Senza nome1"

I want to count the cells that are true for this condition. i'm tring with

for each c In oRange.CellFormatRanges
   if (c.CellBackColor =     oRed4Condition(3).Value) then
     checkResult = checkResult + 1
   endif
 next c

c

but oRange.CellFormatRanges is not correct... how i can loop all cell and check this condition?

Thanks Daniele
(Edited for better readability by @Lupp )