Solved

VBA adding a DropDown over a cell that flexes with it

Posted on 2012-03-17
2
226 Views
Last Modified: 2012-03-17
Hi. I was given the VBA code below to add a DropDown to a cell. How do I modify it so that it fits into the cell and what code would I add so that if the user changes the cells size the DropDown automatically changes too

With ActiveSheet.DropDowns.Add(142.5, 38.25, 108.75, 24)
    .Top = Range("C1").Top
    .Left = Range("C1").Left
End With
0
Comment
Question by:murbro
2 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
ID: 37732332
Add this to the sheet module

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With ActiveSheet.DropDowns.Add(142.5, 38.25, 108.75, 24)
    .Top = Range("C1").Top
    .Left = Range("C1").Left
    .height= Range("C1").height
    .width= Range("C1").width
End With
End Sub

Open in new window


This will be triggered every the cursor is moved on the sheet but not when the cell height or width is modifies.
0
 

Author Closing Comment

by:murbro
ID: 37733252
Thanks very much
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

831 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