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

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
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,215,415
Messages
6,124,764
Members
449,187
Latest member
hermansoa

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