How to Scroll listbox to show last entered item?

cmxulb

Board Regular
Joined
Nov 24, 2020
Messages
52
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

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Is the ListBox embedeed in a worksheet or added to a userform ? And how are you populating the Listbox ?
Do you have any code ?
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,213,489
Messages
6,113,953
Members
448,535
Latest member
alrossman

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