Dynamically sizing ListBox at runtime on Mac

Rocket2

New Member
Joined
Aug 20, 2019
Messages
2
Greetings, I am posting this thread as a last resort after days of searching google and trying different approaches on my own.

The goal is to change the Height property of a ListBox at runtime so that it is large enough to show only the populated rows (which can be few or many depending on previous options).

On Windows, I used a break on a userform, used the immediate window to find the Height property of said ListBox, then counted the visible rows. After quick division I wrote a piece of code that multiplies the ListBox.ListCount by that number and poof, it works. The issue now, is that this has to work on both Windows AND Mac. The same process on the Mac did NOT WORK. I can't seem to figure out where the disconnect is/what is different about the Mac ListBox. Any advice or suggestions?
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
welcome to MrExcel
I only use window so unable to test anything
But I did spot this which may help you indirectly
 
Upvote 0
Thank you Yongle. Here is what I have figured out since my post. To resize the Height of a listbox with font size of 11 on a Mac assign this calculation to the .Height property at runtime:

Listbox1.Height = (Me.Listbox1.ListCount * 15) + 10
Listbox1.IntegralHeight = True

This worked for me over and over again with few or many items. Cheers!
 
Upvote 0

Forum statistics

Threads
1,214,927
Messages
6,122,309
Members
449,080
Latest member
jmsotelo

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