Quantcast
Channel: Apache OpenOffice Community Forum
Viewing all articles
Browse latest Browse all 1291

Macros and UNO API • Macro Function to set Data Validity

$
0
0
I've written the following function to create validity lists for a column:

Code:

Function ValidList(aSheet,R1,R2,List,vType)  oRange = aSheet.getCellRangeByName(R1 & ":" & R2)  oValidation = oRange.Validation : oValidation.setFormula1(List)  oValidation.IgnoreBlankCells = True : oValidation.ShowList = 2   oValidation.Type = vType : oRange.Validation = oValidation End function
aSheet is the current ActiveSheet, R1 is the column & first row of the range, R2 is the column and last row of the range
List is the formula for the vType which is the integer value for com.sun.star.sheet.ConditionOperator enum

When I call the function with

Code:

Call ValidList(rSheet, "B8", "B27", "IF(OR($A8="""";$D$2<$A$5);"""";IF($Items.$A$2:$A$2500=$A8;IF($Items.$G$2:$G$2500=1;$Items.$C$2:$C$2500)))", 6)
I get the proper validation rows for B8 to B27 with $A8 to $A27.

If I then call the function with

Code:

Call ValidList(rSheet, "C8", "C27", "IF(OR($A8="""";$G$5=0);"""";IF($Items.$A$2:$A$2500=$A8;IF($Items.$G$2:$G$2500=1;$Items.$C$2:$C$2500)))", 6)
the validation rows for C8 to C27 are $A15 to $A34

Anyone able to offer an explanation for this behavior? The calls are issued one after the other to set Data Validity for the cells B8 to B27 and then C8 to C27 with the formulas shown. Why it would properly enumerate the rows in the first call but not in the second one is a mystery I cannot solve.

Statistics: Posted by Bal — Fri Sep 27, 2024 4:55 pm



Viewing all articles
Browse latest Browse all 1291

Latest Images

Trending Articles



Latest Images