I'm having an issue with the VBA Sort function when using a button to activate the Sort. The code seems to work one time when I first try it, but then does not work after that.
Columns A-G need to be sorted based on data in column D for "Symbol" button, or column E for "Entry Date" button. I am using cell names to indicate location as this "Jumper" section will move down the sheet as more records are added above. (and columns B & C are blank and need to remain blank)
Here is the code that is not working, and I have attached a stripped down version of the document. The macros in question are entitled "Sort_Jumper_Symbol" and "Sort_Jumper_Entry".
What am I doing wrong?
Sub Sort_Jumper_Symbol()
Dim symb As Range
Dim entr As Range
Dim Jump As Range
Dim srtX As Integer
Set Jump = ActiveSheet.Buttons(Application.Caller).TopLeftCell
Set symb = Jump.Offset(1, 0)
Set entr = Jump.Offset(1, 1)
srtX = Range(Jump.Offset(1, -3), Jump.Offset(1, -3).End(xlDown)).Count
'ActiveCell.Offset(0, -10).Select
'Range(ActiveSheet.Buttons(Application.Caller).TopLeftCell.Offset(1, -1), ActiveSheet.Buttons(Application.Caller).TopLeftCell.Offset(srt, 1)).Sort [G1123], xlAscending, Header:=xlYes
With ActiveSheet.Sort
.SortFields.Add Key:=Range("JumpSym"), Order:=xlAscending
.SortFields.Add Key:=Range("JumpEntry"), Order:=xlAscending
.SetRange Range(Jump.Offset(1, -3), _
Jump.Offset(srtX + 1, 3))
.Header = xlNo
.Apply
End With
Jump.Offset(1, 0).Select
End Sub
Bookmarks