Avatar of Murray Brown
Murray Brown
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Excel VBA ComboBoxes added not fitting properly into cells

Hi. I am using the following code to ass a ComboBox to every cell in a selection.
I need the cells to fit properly but they aren't as shown in the picture. How do I get them to fit properly

Sub ControlToCell()
     
    Dim iLeft As Integer
    Dim iTop As Integer
    Dim iWidth As Integer
    Dim iHeight As Integer
    Dim cell As Range
     
    For Each cell In Selection
       
        cell.Select
        iLeft = ActiveCell.Left
        iTop = ActiveCell.Top
        iWidth = ActiveCell.Width
        iHeight = ActiveCell.Height
         
          ActiveSheet.OLEObjects.Add(ClassType:="Forms.ComboBox.1", Link:=False _
        , DisplayAsIcon:=False, Left:=iLeft, Top:=iTop, Width:=iWidth, Height:= _
        iHeight).Select
       
       
    Next cell
     
End Sub
image3.png
Microsoft Excel

Avatar of undefined
Last Comment
Murray Brown

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Norie

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
dlmille

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Murray Brown

ASKER
Thanks very much
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy