Here's an example of a method that will allow a QlikView macro to look at a value inside a sheet object like a straight table and put the value into a variable. Then the variable can be used in an expression like a text box or small chart. Most of the time, something like this could be accomplished with an expression in the variable that produces the same value as what you see in the chart. But a macro would be useful when duplicating the chart value with an expression would be difficult because of varying sort sequences or calculated dimensions in the chart, etc.
This is the macro code:
Sub Get_XTOTAL
Application.WaitForIdle
set cell=ActiveDocument.GetSheetObject("CH45").GetCell(1,7)
ActiveDocument.Variables("vXTOTAL").SetContent cell.text, True
set cell=nothing
End Sub
Then the macro updates the value in the document variable named vXTOTAL. When written as in this example, the variable must already exist, so create the variable before executing the macro.
When I use a macro like this, I set up a trigger to execute the macro as needed, usually when a selection changes.
★ ★ ★