[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Excel VBA ComboBoxes added not fitting properly into cells

Posted on 2012-03-17
3
Medium Priority
?
276 Views
Last Modified: 2012-03-18
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
0
Comment
Question by:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 35

Accepted Solution

by:
Norie earned 1000 total points
ID: 37733372
Try adding a pixel (I think they're pixels, might be points) or two to the width and height.
0
 
LVL 42

Assisted Solution

by:dlmille
dlmille earned 1000 total points
ID: 37733380
This is what I use with my DynamicDV! utility:http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/A_6429-Part-II-Drop-Down-List-with-Unique-Distinct-Values-ComboBox-ListBox-and-Data-Validation-List-Bonus.html

Dim cboTemp As OLEObject
Dim Target As Range

    Set Target = Range("A15")
   
    Set cboTemp = ActiveSheet.OLEObjects.Add(classtype:="Forms.ComboBox.1")
    cboTemp.Name = "TempCombo"
       
           
    With cboTemp

        .Visible = True
        .Left = Target.Left
        .Top = Target.Top
        .Width = Target.Width + 5
        .Height = Target.Height + 5

    End With
0
 

Author Closing Comment

by:Murray Brown
ID: 37735067
Thanks very much
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question