Display the last 5 current rows of Rowsource in Listbox1 of Userfomr1 using a dynamic named range...

chazrab

Well-known Member
Joined
Oct 21, 2006
Messages
884
Office Version
  1. 365
Platform
  1. Windows
Title should be self explanatory ?
Rowsource will always increase as rows are added, but the last 5 most current rows will always be displayed.
Rowsource = Sheet1! A2: G360 - but as mentioned, that will increase - i.e, cols are static, rows dynamic - row 360 will soon become row 361, etc.

My thinking is to define Rowsource as a dynamic Named Range, move to the last row in the range and select and display all 4 rows above it in the listbox, but I don't know how to do that.

I just want to see the last 5 entries displayed in the listbox. That's it in a nutshell.

Should be simple enough, I just can't see it.
Can someone please help me figure this out ?
cr
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
1594880626725.png

If your listbox has height only to show 5 records, then you can use the following:

VBA Code:
Private Sub UserForm_Activate()
  With ListBox1
    .RowSource = "Sheet1!A2:G" & Sheets("Sheet1").Range("A" & Rows.Count).End(3).Row
    .TopIndex = .ListCount
  End With
End Sub
 

Attachments

  • 1594880455204.png
    1594880455204.png
    42 KB · Views: 3
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,249
Members
449,075
Latest member
staticfluids

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