Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to call a Macro for Tab

Hi Guys,

I am quite new user to Qlikview. Please help me on this.

In the Qlikview Applications, I have created 3 tabs, with same source file (.xls), Now I need to apply different filters for each Tabs.

Could you please let me know how to call a Macro only to Tab1 and apply Status condition as Open Errors. i,e when I click on Tab1, Macro should run and filter only Open Errors, similarly when I click on tab 2, Macro should run and filter only for Closed Errors.

Your help is much Appreciated

-Thanks

Suchi

1 Solution

Accepted Solutions
Not applicable
Author

Hi Suchitra,

Yes in near future, you can copy the 2 lines and change the values. But it is not advisable to have macro for more values to be selected. It effects in performance issue whenever you open the sheet/tab. Try to get some alternate solutions for selecting more values.

Regards
Rajesh

View solution in original post

9 Replies
Not applicable
Author

Hi Suchitra,

You can use the below macro to select a value in status field;

Sub Tab1
ActiveDocument.Fields("Status").Select "Open Errors"
End Sub


You can call this macro on activate of sheet. Right Click on the Sheet --> Go to Trigers --> Click on OnActive --> Assign the macro "Tabq". Likewise add different macro's for different tabs.

Regards
Rajesh

Not applicable
Author

Thanks Rajesh,

i have written the code



Sub

Tab1

"APStatus_DFS79.92"

). Select "1. DETECTED" and

"1.1 TO BE EVALUATED"

End



Sub

This code is not working, as i have included 2 status condition, please help me to fix this.





Not applicable
Author

Hi Suchitra,

The macro may look like this;

Sub Tab1()
ActiveDocument.Fields("APStatus_DFS79.92").Clear
SET F = ActiveDocument.Fields("APStatus_DFS79.92")
SET FV = f.GetNoValues 'empty array
FV.Add
FV.Add
FV(0).Text="1.DETECTED"
FV(0).IsNumeric=False
FV(1).Text="1.1 TO BE EVALUATED"
FV(1).IsNumeric=False
f.sELECTvALUES fv
End Sub


you can verify the API guide which has been installed along with your Qlikview in C:\Program Files\QlikView\Documents

Note: Pls don't copy the code directly into the forum. First copy the script to a notepad and then copy from notepad and paste in the forum.

Regards
Rajesh

Not applicable
Author

Sorry change the last line to below

F.SelectValues FV

Not applicable
Author

Sub

Tab1()

"APStatus_DFS79.92"

).Clear

SET

F = ActiveDocument.Fields("APStatus_DFS79.92")

SET

FV = f.GetNoValues 'empty array'

"1.DETECTED"IsNumeric

=False"1.1 TO BE EVALUATED"IsNumeric=False

End



Sub



Not applicable
Author

This Code is not working, It is only selecting "1.1 To Be Evaluated" status, Macro has to select both Status

Not applicable
Author

Hi,

Verify the values; whether the values in the Status field and value that you defined in the macro are in same case, correct spelling, any spaces inbetween bcoz QlikView is "CASE CENCITIVE".

Regards

Not applicable
Author

Hi,

Now its working fine.... Thanks Rajesh...

One last questions, In future if i need to include some more status then what code i need to use...

like do i need to repeat the following code replacing with 1 with 2 and so on... or how to include some more values

FV(0).Text =



"3.1 PENDING"

Fv(0).text IsNumeric

=False "

FV(1).Text =

"1. DETECTED"

FV(0).text IsNumeric



=False





Not applicable
Author

Hi Suchitra,

Yes in near future, you can copy the 2 lines and change the values. But it is not advisable to have macro for more values to be selected. It effects in performance issue whenever you open the sheet/tab. Try to get some alternate solutions for selecting more values.

Regards
Rajesh