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
Solved

VBA adding a DropDown over a cell that flexes with it

Posted on 2012-03-17
2
227 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 Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

856 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