Option Explicit
#If VBA7 Then
Private Declare PtrSafe Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
#Else
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
#End If
Private Sub SetHeight(ByVal LBox As MsForms.ListBox, ByVal NumberOfEntries As Long)
Const SM_CYEDGE = 46&
With LBox
NumberOfEntries = IIf(NumberOfEntries > .ListCount, .ListCount, NumberOfEntries)
.Height = ((9.75 * NumberOfEntries) + IIf(.SpecialEffect = fmSpecialEffectFlat, 0, GetSystemMetrics(SM_CYEDGE)))
End With
End Sub