how populate the last entered data in listbox when run userform

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
1,429
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
hi
I would when run the userform I would show the last entered data .
in pic 1 when enter data from the first time

1.PNG




in pic2 enter new data
\
2.PNG



pic 3 it populate the last entered data with ignore the old data
3.PNG





this is the current code to show all of data
VBA Code:
Private Sub UserForm_Initialize()
   Dim LastRow As Long
    LastRow = Range("A" & Rows.Count).End(xlUp).Row    '<---- ??????
    With ListBox1
        .ColumnCount = 6    '<---- Change to 18??????
        .ColumnWidths = "70;70;100;70;70;70"    '<---- 18 x each column width
        .List = Range("A1:F" & LastRow).Value    '<---- Change the "I" to the column number used above ( S = 18)
    End With
End Sub
thanks
and so on if I enter new data it will populate new data in listbox with ignores the old data
note: if you want depending on date to do that I don't mind . it's up to you how should do it.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
It works on my computer .....
VBA Code:
Private Sub UserForm_Initialize()
    Dim LastRow As Long
    LastRow = Range("A" & Rows.Count).End(xlUp).Row
    Dim MaxDt, CntLatestDate As Long
    MaxDt = WorksheetFunction.Max(Range("A:A"))
    CntLatestDt = Application.WorksheetFunction.CountIf(Range("A:A"), MaxDt)
    With ListBox1
        .ColumnCount = 6
        .ColumnWidths = "70;70;70;70;70;70"
        .RowSource = ("A" & LastRow - CntLatestDt + 1) & ":F" & LastRow
    End With
End Sub
 

Attachments

  • LastDate.JPG
    LastDate.JPG
    109.3 KB · Views: 8
Upvote 0
Solution
my apologies ! I implemented in wrong data in other file . based on your answering in post #12 works perfectly .
many thanks for your assistance ! ;)
 
Upvote 0

Forum statistics

Threads
1,215,039
Messages
6,122,799
Members
449,095
Latest member
m_smith_solihull

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