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?
 

Some videos you may like

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,977
Office Version
  1. 365
Platform
  1. Windows
welcome to MrExcel
I only use window so unable to test anything
But I did spot this which may help you indirectly
 

Rocket2

New Member
Joined
Aug 20, 2019
Messages
2
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!
 

Watch MrExcel Video

Forum statistics

Threads
1,122,469
Messages
5,596,325
Members
414,053
Latest member
Dual Showman

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