Developing a form with filter parameters which will generate a excel spreadsheet when click on the Excel button. At the same time, the form has capability to decide the sort for 2 levels which is then pass to excel using VBA.
The sort VBA code works fine whenever I opened the form for the first time and click on the Excel button. Subsequent clicks of the Excel button will render the sort to not work.
I have tested on early binding, and late binding. Still gives the same behavior.
Why does VBA allow the sort code to work the first time? and subsequent times, the code can execute but does not display the result I want?
Here is my sort code:
TIA..
The sort VBA code works fine whenever I opened the form for the first time and click on the Excel button. Subsequent clicks of the Excel button will render the sort to not work.
I have tested on early binding, and late binding. Still gives the same behavior.
Why does VBA allow the sort code to work the first time? and subsequent times, the code can execute but does not display the result I want?
Here is my sort code:
Code:
Selection.Sort Key 1:=Range(strLevel1Sort), Order1:= xlAscending, Key 2:=Range(strLevel2Sort), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, Matchcase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal
Active Window.SmallScroll Down:= -6
TIA..