Solved

VBA adding a DropDown over a cell that flexes with it

Posted on 2012-03-17
2
224 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now