How to Scroll listbox to show last entered item?

cmxulb

New Member
Joined
Nov 24, 2020
Messages
42
Office Version
  1. 365
Platform
  1. Windows
Hello,
How to auto Scroll listbox to show last entered item? Every time an item is entered I would like it to the auto show the last item entered?
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
8,203
Office Version
  1. 2016
Platform
  1. Windows
Is the ListBox embedeed in a worksheet or added to a userform ? And how are you populating the Listbox ?
Do you have any code ?
 

cmxulb

New Member
Joined
Nov 24, 2020
Messages
42
Office Version
  1. 365
Platform
  1. Windows
Is the ListBox embedeed in a worksheet or added to a userform ? And how are you populating the Listbox ?
Do you have any code ?
added to a userform.


Sub Submit()

Dim Sh As Worksheet
Dim iRow As Long

Set Sh = ThisWorkbook.Sheets("Database")

If frmForm.txtRowNumber.Value = "" Then

iRow = [Counta(Database!A:A)] + 1
Else

iRow = frmForm.txtRowNumber.Value

End If


With Sh

.Cells(iRow, 1) = "=Row()-1" 'Dynamic Serial Number

.Cells(iRow, 2) = frmForm.txtMaterialID.Value

.Cells(iRow, 3) = IIf(frmForm.optLarge.Value = True, "Large", "Small")

.Cells(iRow, 4) = frmForm.cmbValve.Value

.Cells(iRow, 5) = IIf(frmForm.CheckYes.Value = True, "Yes", "No")

.Cells(iRow, 6) = frmForm.txtintfineflow.Value

.Cells(iRow, 7) = frmForm.txtintcoarseflow.Value

.Cells(iRow, 8) = frmForm.txtFineFlow.Value

.Cells(iRow, 9) = frmForm.txtCoarseFLow.Value

.Cells(iRow, 10) = user

.Cells(iRow, 11) = [Text(Now(), "MM-DD-YYYY HH:MM:SS")]

.Cells(iRow, 12) = frmForm.txtComments.Value



End sub




Private Sub UserForm_Activate()

End Sub

Private Sub UserForm_Initialize()

Call Reset

End Sub



Private Sub lstDatabase_AfterUpdate()

End Sub

Private Sub lstDatabase_BeforeDragOver(ByVal Cancel As MSForms.ReturnBoolean, ByVal Data As MSForms.DataObject, ByVal X As Single, ByVal Y As Single, ByVal DragState As MSForms.fmDragState, ByVal Effect As MSForms.ReturnEffect, ByVal Shift As Integer)

End Sub

Private Sub lstDatabase_Change()

End Sub

Private Sub lstDatabase_Click()



End Sub
 

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
8,203
Office Version
  1. 2016
Platform
  1. Windows
It is not clear, from the code you posted, where the Listbox control is .

Anyway, here is a simple example that you should be able adapt and which shows how a listbox is scrolled to the last item each time a new value is added to the listbox :

VBA Code:
Dim i As Long

For i = 1 To 100
    ListBox1.AddItem i
    ListBox1.Selected(i - 1) = True
Next i
 

Watch MrExcel Video

Forum statistics

Threads
1,130,170
Messages
5,640,574
Members
417,151
Latest member
ChickenTenderer

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
Top