Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro to change color in a cell of a straight table

Hi ! I wanted to know if you could please help me to do this in a Qlikview macro (VBScript). I tried it using this code but it only modifies one whole column, not one specific cell:

set table = ActiveDocument.GetSheetObject("CH47")

set prop = table.GetProperties

for RowIter = 0 to table.GetRowCount-1

for ColIter =1 to table.GetColumnCount-1

     set cell = table.GetCell(RowIter,ColIter)

     set ev = prop.Expressions.Item(0).Item(0).Data.ExpressionVisual

     ev.CellVariations(0).TotalBgColor.Col = RGB(100,0,0)

next

next

prop.TableProperties.StyleNumber = -1

table.SetProperties prop

THANKS!

1 Solution

Accepted Solutions
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   You can do this without macro.

   Go to properties of chart -> Expression Tab-> Click + sign.

   Here you will find the option called, Background color.

   Clik on it.

   At right type the condition below the definition.

   Say for example.

   if(Sum(Value) =100, rgb(100,0,0))

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!

View solution in original post

19 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   Seems that you want to change the colors of the rows and column of the chart..?

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Hi,

First I check if the content of that cell of the straight table meets some conditions, if it doesnt meet them, I want to change the background colour of that specific cell. Other idea I thought would be to add a flag in another cell in the straight table, for example setting that cell with the value "N", but I dont know how to do it in a macro either.

Thanks for your help.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   You can do this without macro.

   Go to properties of chart -> Expression Tab-> Click + sign.

   Here you will find the option called, Background color.

   Clik on it.

   At right type the condition below the definition.

   Say for example.

   if(Sum(Value) =100, rgb(100,0,0))

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

The problem is that that content in the cell has to meet several conditions. To be more specific, that cells contains a name, for example ABC:EUROPE:02 , and I have to check if that name is valid according to several rules (for example that the first parts is only 3 characters, that the second one is a valid continent, etc) . So I think such a complicated condition is not possible to do it adding an expression in the Table settings/Background Color, etc

What do u think?

Thanks again for your super fast reply.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

HI,

   It is possible, how can you conclude without trying it.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Is there any function there to parse a String according to one character? I mean, if you have for exampe ABC:EUROPE:02 , to get an array or something like that with ABC , EUROPE  and 02 (the fields separated by the character ":"

Thanks

montubhardwaj
Specialist
Specialist

Hi Yo,

If you think you have so many conditions to check for, then do it in the script. Create flags and then use in the condition. That will reduce your big formula and also it will give better performence.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   Yes there are many string functions available in qlikview.

   Go to help and find string functions.

   One of them is subfield.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

And is it possible to write there a whole code defining expressions, with loops and so on?