Ask Your Question
0

conditional formatting and clearContents [closed]

asked 2013-02-07 22:04:12 +0200

k3tw13z3l gravatar image

Using the following lines in my Calc macro:

oRange = ThisComponent.Sheets.getByName("MySheet").getCellRangeByName("I21:AC47")
oRange.clearContents(1)

It also clears the Conditional formatting, why ?

clearContents(1) should only remove a VALUE right ?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2015-10-21 15:40:00.556440

Comments

Yes, of course - you are right: clearContents(1) remove a VALUE only. Your macro did it in my test sheet (conditional formats wasn't changed). What conditions and what styles you use when macro not work properly?

JohnSUN gravatar imageJohnSUN ( 2013-02-08 09:32:14 +0200 )edit

Well to be honest I didn't try it in a new sheet...(Iwill do that) It used to work but after a certain update (I do know when unfortunately, because I didn't notice the loss of the conditional format). I use a formula IF(I$60= "c") and apply a defined 'My_Style' some colour stuff.

k3tw13z3l gravatar imagek3tw13z3l ( 2013-02-08 22:16:20 +0200 )edit

Sorry, I do not quite understand the meaning of the condition. "If the value in line 60 is exactly equal to "C" ... So what? Then?.. Else?.. Maybe you didn't mean IF(), but just a comparison?

JohnSUN gravatar imageJohnSUN ( 2013-02-11 09:00:21 +0200 )edit

Eh, If I$60 contains a "c" Then apply style 'My_Style' is what I'm doing for a row so I have a visual cue about the state (contained in the I$60 cell) of the sheet, if you understand what i'm saying...

k3tw13z3l gravatar imagek3tw13z3l ( 2013-02-11 10:19:54 +0200 )edit

Yes, I think I understand what you are saying :-) I meant that the conditional format in this case can be written without using the function IF().

JohnSUN gravatar imageJohnSUN ( 2013-02-11 12:13:35 +0200 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2013-02-11 12:17:29 +0200

JohnSUN gravatar image

Your macro works correctly. In the range "I21:AC47" removed only numbers. Strings, formulas and conditional formats are in place.

ClearCondFormat.ods - your macro and my variant of conditional formatting

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-02-07 22:04:12 +0200

Seen: 1,324 times

Last updated: Feb 11 '13