Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

2 macros for one sheet problems

Hi everyone,

I'm very new to macros but have created one in where when a sheet is selected a certain field is automatically selected:

ActiveDocument.Fields("Active").Select ActiveDocument.Evaluate("Active")

However, I want to create a similar macro that when I leave the sheet the field selection is removed. I know how to do this but it won't seem to let me create the second macro for some reason? Anyone know why?

Thanks,

5 Replies
Not applicable
Author

What do you mean by, "won't seem to let me create the second macro?" Are you able to create a different Sub to handle the OnLeaveSheet?

What are you using to Deselect the field? You could use ToggleSelect (instead of Select). If that field is Selected, it will then unselect it (but if the field is not selected, it will select it). You could also clear that field, but that will clear everything.

Not applicable
Author

I'm going to sheet properties on the relecant sheet and then macros. I have one macro on the OnActivateSheet Trigger. I then try to create a different one on the OnLeaveSheet trigger, but when I do this it ends up editing my initial (OnActivateSheet) macro. Any ideas why this would be the case?

I would like my leaving the sheet macro to be:

Sub ClearField
ActiveDocument.fields(Active).Clear
End Sub


What I want is one macro for when I click on this sheet and a separate macro so that then I leave the sheet the field is deactivated.

I would appreciate any help.

Not applicable
Author

Hi everyone,

Apologies - I thought a new module window was needed for each macro! My mistake. Got it working now. Thanks

amit_shetty78
Creator II
Creator II

Just curious why did you use macro to select / unselect a field value and why not set actions on the sheet itself. (Sheet Properties >> Actions >> Action Type >> Selection)

Not applicable
Author

I'm still using version 8.5