• Un the Home userform.

    Sub SortData(w As Worksheet, Direction As Integer)
    '1. smallest to largest
    '2. largest to smallest
    Select Case Direction
    Case 1: w.Range("A1").CurrentRegion.Sort Key1:=Range("A1"), Header:=xlYes, Order1:=xlAscending
    Case 2: w.Range("A1").CurrentRegion.Sort Key1:=Range("A1"), Header:=xlYes, Order1:=xlDescending
    End Select
    End Sub

    Called in the Show_In_Out_Data Procedure

  • I've added code to sort the IN_OUT sheet to show the latest record first.

    I can't really understand what you are doing, there seems way too many operations in your userform than necessary.

    Hi Roy,

    Thank you so much for your help.

    I know this is so chaotic. I just don't want to delete some codes, I am just afraid something might not work if I delete some operations in my userform.

    This a work in progress and I am hoping to improve this project as I go along.

    Thank you so much for your patience and for your help.


  • This solution solves one problem for you, but adds another one, that is, the date problem I think is solved, but by this method the column headers disappear, it is an EXCEL / VBA fault.

    The solution is to put a label, for the headers, otherwise the solution is just as RoyUK says.

    Hi JCabral,

    Thanks for the help, it's working,

    I can just add labels since the headers were gone.

    Thanks again,


  • I think sorting the UserForm ListBox is unnecessary, you seem to be creating a sheet for the show data to populate the ListBox, so sorting that sheet makes more sense. Especially as you lose the headers.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!