Scrolling to the bottom of listbox in VBA

AVAYA123456

New Member
Joined
Jun 24, 2015
Messages
3
Hi,

i am trying to display updates of a process to user using listbox. That is if user hits a command button i will add few lines to the already existing data in the list box using .AddItem. but after i did the list box always shows top lines and not the newly added lines in the bottom. Is it possible to additem to listbox and scroll to the bottom of listbox thru vba or do we have anyother way on doing this?

Thanks.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
You can use the TopIndex property. Here's an example...

Code:
[color=darkblue]Private[/color] [color=darkblue]Sub[/color] CommandButton1_Click()
    [color=darkblue]With[/color] Me.ListBox1
        .AddItem "Item1"
        .AddItem "Item2"
        .AddItem "Item3"
        .TopIndex = .ListCount - 1
    [color=darkblue]End[/color] [color=darkblue]With[/color]
[color=darkblue]End[/color] [color=darkblue]Sub[/color]

Hope this helps!
 
Upvote 0
Hi Domenic,

Thank you very much for the code you have shared. It's working well!!!
Thanks again!
 
Upvote 0

Forum statistics

Threads
1,216,075
Messages
6,128,668
Members
449,463
Latest member
Jojomen56

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