Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am brand new to Macros and just need a simple macro that I will run OnActivateSheet that will:
1. Set a Variable: vTest
= if (vBlob = 'test', 'Value1', 'Value2')
2. Select in Field: myFilter
= '>=$(EndDate)'
All the example macros are very complex and I am not sure what the minimum is I need to include to just perform the above actions. I had these actions set up individually (without macro), but need to assure that the variable is set before the field is selected.
Thanks
You don't need a macro for this and, in fact, I highly recommend avoiding them whenever possible. Go to Settings > Sheet Properties > Triggers < OnActivateSheet > Add Action(s) > Add > External > Set Variable for the first one. Then do the same thing, but select Selection > Select in Field for the second one.
Some background on my I am looking into using a macro: Sheet OnActivateSheet action not working properly | Qlik Community
Thanks Rebecca, I agree, I was hoping to do this without a macro, but here is some background:
Sheet OnActivateSheet action not working properly | Qlik Community
I agree with Rebecca Camper. You can accomplish this using triggers. Macros should be a last resort. But if you are curious as to the code, here is some code that does what you ask as a macro:
sub Test
set vBlob = ActiveDocument.Variables("vBlob")
set vTest = ActiveDocument.Variables("vTest")
set EndDate = ActiveDocument.Variables("EndDate")
if vBlob.GetContent.String = "test" then
vTest.SetContent "Value1",true
else
vTest.SetContent "Value2",true
end if
ActiveDocument.Fields("myFilter").Select ">=" + EndDate.GetContent.String
end sub
Again, I would recommend Rebecca's way using triggers.
Hope this helps!