Displays data from oldest to newest VBA

Attrazion

New Member
Joined
Mar 11, 2023
Messages
25
Office Version
  1. 365
Platform
  1. Windows
Hi everyone. Good day. I just want to ask for help regarding my problem on this one.

This is the output when I run my macro, it's fetching the data from "Precious - Sol - Angel" which is the Notes data based on today's date. I don't have a problem with this.

My problem is when the macro is executed, I need to display the data from oldest to newest based on the month and date of the Notes column Can anyone help me?

This is the code I have right now.

Book11.xlsx
AB
1DateName
203/05/2023Adrian Santos
303/06/2023Adrian Sanchez
403/06/2023Ranch Book
503/07/2023Auto Sum
603/08/2023Fernandez
703/09/2023Tolentino
803/10/2023Loti
902/04/202304/01: borrowed 21$
1003/12/2023Duke
Precious
Cell Formulas
RangeFormula
A9A9=TODAY()


Book11.xlsx
AB
1DateName
203/05/2023Adrian Santos 1
303/06/2023Adrian Sanchez 2
403/06/2023Ranch Book 3
503/07/2023Auto Sum 4
603/08/2023Fernandez 5
703/09/2023Tolentino 6
803/10/2023Loti 7
902/04/202304/02: borrowed 25$
1003/12/2023Duke 9
Sol
Cell Formulas
RangeFormula
A9A9=TODAY()


Book11.xlsx
AB
1DateNotes
203/05/202303/05: borrowed 11$
303/06/202303/06: borrowed 11$
403/06/202303/06: borrowed 12$
503/07/202303/07: borrowed 13$
603/08/202303/08: borrowed 14$
703/09/202303/09: borrowed 15$
803/10/202303/10: borrowed 16$
911-Mar-2303/11: borrowed 17$
1003/12/202303/12: borrowed 18$
1102/04/202303/29: borrowed 19$
Angel
Cell Formulas
RangeFormula
A11A11=TODAY()



These are the results and my code that I need to sort from lowest to newest. Can someone help me?
1680418623161.png


VBA Code:
Private Sub UserForm_Initialize()

  Dim firstSheet As String
  Dim secondSheet As String
  Dim thirdSheet As String
  Dim Result As String
  
  firstSheet = Worksheets("Precious").Range("D2").Value
  secondSheet = Worksheets("Sol").Range("D2").Value
  thirdSheet = Worksheets("Angel").Range("D2").Value
  
  Results = firstSheet & vbCrLf & secondSheet & vbCrLf & thirdSheet
  
  Me.TextBox1.Value = Results
  TextBox1.MultiLine = True
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Hi everyone. Good day. I just want to ask for help regarding my problem on this one.

This is the output when I run my macro, it's fetching the data from "Precious - Sol - Angel" which is the Notes data based on today's date. I don't have a problem with this.

My problem is when the macro is executed, I need to display the data from oldest to newest based on the month and date of the Notes column Can anyone help me?

This is the code I have right now.

Book11.xlsx
AB
1DateName
203/05/2023Adrian Santos
303/06/2023Adrian Sanchez
403/06/2023Ranch Book
503/07/2023Auto Sum
603/08/2023Fernandez
703/09/2023Tolentino
803/10/2023Loti
902/04/202304/01: borrowed 21$
1003/12/2023Duke
Precious
Cell Formulas
RangeFormula
A9A9=TODAY()


Book11.xlsx
AB
1DateName
203/05/2023Adrian Santos 1
303/06/2023Adrian Sanchez 2
403/06/2023Ranch Book 3
503/07/2023Auto Sum 4
603/08/2023Fernandez 5
703/09/2023Tolentino 6
803/10/2023Loti 7
902/04/202304/02: borrowed 25$
1003/12/2023Duke 9
Sol
Cell Formulas
RangeFormula
A9A9=TODAY()


Book11.xlsx
AB
1DateNotes
203/05/202303/05: borrowed 11$
303/06/202303/06: borrowed 11$
403/06/202303/06: borrowed 12$
503/07/202303/07: borrowed 13$
603/08/202303/08: borrowed 14$
703/09/202303/09: borrowed 15$
803/10/202303/10: borrowed 16$
911-Mar-2303/11: borrowed 17$
1003/12/202303/12: borrowed 18$
1102/04/202303/29: borrowed 19$
Angel
Cell Formulas
RangeFormula
A11A11=TODAY()



These are the results and my code that I need to sort from lowest to newest. Can someone help me?
View attachment 88864

VBA Code:
Private Sub UserForm_Initialize()

  Dim firstSheet As String
  Dim secondSheet As String
  Dim thirdSheet As String
  Dim Result As String
 
  firstSheet = Worksheets("Precious").Range("D2").Value
  secondSheet = Worksheets("Sol").Range("D2").Value
  thirdSheet = Worksheets("Angel").Range("D2").Value
 
  Results = firstSheet & vbCrLf & secondSheet & vbCrLf & thirdSheet
 
  Me.TextBox1.Value = Results
  TextBox1.MultiLine = True
Hello @Attrazion

Why can't you sort the dataset the way you want?
Set the Recorder on, and sort the dataset the way you like it, and then CLEAN UP the recorded code!

Let me know if there is anything that I am missing.

Montry
 
Upvote 0

Forum statistics

Threads
1,214,967
Messages
6,122,503
Members
449,090
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top