I have basic sort code that sorts my information correctly and it uses a button. But if I press the button again (a second time), it moves my data up if there are blank row/rows and I don't want it to fill in the blank rows. I would like to have a msgbox that says my data is already sorted.
In my code its looking at Column L. In the cell I put 1, 2, 3, 4, and 5 numbers. They represent Week, Month, Quarterly, SemiAnnual and Annual (1=week, 2=Month etc.) these numbers are static with the row. I believe I need an If else statement but when I searched, I didn't find much information on it.
In my code its looking at Column L. In the cell I put 1, 2, 3, 4, and 5 numbers. They represent Week, Month, Quarterly, SemiAnnual and Annual (1=week, 2=Month etc.) these numbers are static with the row. I believe I need an If else statement but when I searched, I didn't find much information on it.
VBA Code:
Private Sub CommandButton2_Click()
Application.ScreenUpdating = False
Dim lastrow As Long
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set wsData = ThisWorkbook.Worksheets("ConMon Due")
Set rngData = wsData.Range("A4:L4" & lastrow)
rngData.Sort key1:=Range("L4"), order1:=xlAscending, Header:=xlYes
Application.ScreenUpdating = True
End Sub