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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macros

i have following code of marcos,When i Write (end if).before end sub it will not work,,and when i remove it work fine

sub TrendByTimeSwitch()

    set trend_by = ActiveDocument.Fields("Trend_By_Time")

    set values = trend_by.GetSelectedValues

    if values(0).text = "Quarter" then

        ActiveDocument.Fields("C.Quarter").selectPossible

        ActiveDocument.Fields("C.Year_Month").clear

        ActiveDocument.Fields("C.Discharge_Year").clear

        ActiveDocument.Fields("C.FY_Year").clear

        ActiveDocument.Fields("C.R4Q").clear

    elseif values(0).text = "Month" then

        ActiveDocument.Fields("C.Year_Month").selectPossible

        ActiveDocument.Fields("C.Quarter").clear   

        ActiveDocument.Fields("C.Discharge_Year").clear

        ActiveDocument.Fields("C.FY_Year").clear

        ActiveDocument.Fields("C.R4Q").clear

    elseif values(0).text = "CY" then

        ActiveDocument.Fields("C.Discharge_Year", "QASheet").selectPossible

        ActiveDocument.Fields("C.Quarter", "QASheet").clear   

        ActiveDocument.Fields("C.Year_Month", "QASheet").clear

        ActiveDocument.Fields("C.Fiscal_Year", "QASheet").clear

        ActiveDocument.Fields("C.R4Q", "QASheet").clear

    elseif values(0).text = "FY" then

        ActiveDocument.Fields("C.Fiscal_Year", "QASheet").selectPossible

        ActiveDocument.Fields("C.Quarter", "QASheet").clear   

        ActiveDocument.Fields("C.Year_Month", "QASheet").clear

        ActiveDocument.Fields("C.Discharge_Year", "QASheet").clear

        ActiveDocument.Fields("C.R4Q", "QASheet").clear

    elseif values(0).text = "R4Q" then

        ActiveDocument.Fields("C.R4Q", "QASheet").selectPossible

        ActiveDocument.Fields("C.Quarter", "QASheet").clear   

        ActiveDocument.Fields("C.Year_Month", "QASheet").clear

        ActiveDocument.Fields("C.Discharge_Year", "QASheet").clear

        ActiveDocument.Fields("C.Fiscal_Year", "QASheet").clear

endif

end sub

4 Replies
alexandros17
Partner - Champion III
Partner - Champion III

write End If nor EndIf (The space between end and if

let me know

Not applicable
Author

end if after writing error comes..when i remove it works

alexandros17
Partner - Champion III
Partner - Champion III

The syntax is:

      If condition Then
         [Statements]
      [ElseIf condition-n] Then [Statements]
      [Else]
         [Statements]
      End If

so it should need End If, try to evaluate each if and verify if it works.

alsale_1968
Contributor III
Contributor III

hi,

there must be a space between end if.

May be missing a ";" at the end of a sentence?