Option Explicit
Function HasVerticalScrollBar(Ctrl)
Dim q$, Fsz&
Fsz = Ctrl.Font.Size
q = Application.Rept("A" & vbCrLf, Ctrl.ListCount): q = Left(q, Len(q) - 2)
If TypeOf Ctrl.Parent Is UserForm Then
With Ctrl.Parent.Controls.Add("forms.Label.1", "X3Xy")
.Height = Ctrl.Parent.Height: .Caption = q: .Font.Size = Ctrl.Font.Size: .Font.Name = Ctrl.Font.Name
.Font.Bold = Ctrl.Font.Bold: .BorderStyle = Ctrl.BorderStyle: .AutoSize = True
HasVerticalScrollBar = .Height > Ctrl.Height
Ctrl.Parent.Controls.Remove .Name
End With
Else
With ActiveSheet.Shapes.AddLabel(msoTextOrientationHorizontal, 10, 10, 10, 10)
With .TextFrame: .Characters.Text = q: .MarginLeft = 0: .MarginRight = 0: .MarginTop = 0: .MarginBottom = 0: End With
With .Parent.DrawingObjects(.Name)
.Font.Size = Fsz: .Font.Name = Ctrl.Object.Font.Name: .Font.Color = RGB(0, 210, 255)
.HorizontalAlignment = xlHAlignCenter: .VerticalAlignment = xlVAlignCenter
End With
HasVerticalScrollBar = .Height > Ctrl.Height
.Delete
End With
End If
End Function