Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
devans_1
Creator
Creator

Sorting via a macro

Does anyone know how to sort via a macro ? I want the user to be able to use a button to sort. The field to sort on is hidden. I tried

sub Sort

set chart1 = ActiveDocument.GetSheetObject("CH121")
chart1.SortBy 24
end sub

which works as long as the column is not hidden but if it's hidden it fails. I think I need to sort on the field name rather than the column no but I don't know how to do this. Can anyone help ?

5 Replies
Not applicable

Hi,

In the chart order move the expression first and try the below macro:

Sub SortOrder

          Set chart = ActiveDocument.GetSheetObject("CH121")

          Set p = chart.GetProperties

          p.Expressions.Item(1).Item(0).Data.ExpressionData.SortCriteria.SortByNumeric = 1

          chart.SetProperties p

End Sub

Regards,

Kiran Rokkam.

devans_1
Creator
Creator
Author

Thanks for this Kiran. This doesn't work unfortunately. It doesn't give an error - it just doesn't sort.Not sure what is wrong here.

What I did was to have the hidden field displayed but with a column width of zero. That way my sort macro works and the column is not seen. It's not as neat as being able to sort on a hidden field but the the end result is the same.

Not applicable

Can you share your file?

Regards,

Kiran Rokkam.

Not applicable

Just check this out.

Kiran.

devans_1
Creator
Creator
Author

Thanks Kiran. It's appreciated. I'll look at this shortly as I'm on holiday for a while... .