Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
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!

19 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

HI,

   There is not need to write a loop, it will automatically loop for the possible values of the dimensions.

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 Sharma, the problem is that I dont know how to change the cell color running a VBscript. If not, I will be useful as well to know hot to modify fields in a straight table with a macro.

Thanks

Not applicable
Author

Hi Kaushik, I know it will loop for all the possible values, but I just wanted to know if I can write there complex code like loops, variable definitions and so on, cos I thought it could only be written conditional expressions.

Thanks again.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   No loops are not allowed in expression.

   Yes only conditions can be written in that, but you can use nested if statements.

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

What about assignments to variables or creation of temporary variables? I tried it but i think that is not allowed.

Thanks Kaushik

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   Right you cant create  or assign a variable but you can use the values of already created variables.

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

Thanks.

Then, just for curiosity ,do you know if it is possible to change the color cell, or change the value of a cell in the table   with a macro?

Regards.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   Sorry, but i would suggest you not yo use macro, as there is no gurantee of proper functioning of macro in browser.

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

Sorry, I was on holidays 🙂 

Regarding to the macro issue, It was just curiosity yo know if it was possible to do it. I already dit it without the macro.

Thank you for all you help.

Not applicable
Author

Hi again people.

This time I would need to change the color using a macro because I have to compare two fields from different tables that are not related each other.

Thanks a lot!