Annoying problem with viewing validation drop down box

rmtaylor

Board Regular
Joined
Feb 17, 2002
Messages
155
Hi can anyone assist me with this annoying problem
Is there any way that I can control the width of a drop down list as it is shown.
I have created a drop down list to be active in a range of cels, the cell width needs to be small but I would like the full text to be shown when the drop down appears during selection (once selected it is not required to be shown in full the cell). At the moment it only shows 4 characters of each item on the lists. Is it possible to have some control over this.

Thanks in advance for any replies
Robert
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Howdy Robert, yes indeed, here's an example, since you didn't provide ranges. Ranges c7 & f1 have drop down boxes and column H holds your list range (and is sized appropriately).

Since the validation drop downs take the form shape and dynamically create and destroy themselves, if you haven't created other form dropdowns in your worksheet, every one of 'em will be "drop down 1."

Accordingly, place the following macro in the appropriate worksheet class module:<pre>
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim myShp As Shape, Drp As Single
On Error Resume Next
'cells holding drop downs
If Intersect(Target, [f1,c7]) Is Nothing Then Exit Sub
If Target.Validation.Type = xlValidateList Then
Set myShp = ActiveSheet.Shapes("Drop Down 1")
Drp = myShp.Width - Target.Width
'Column holding list, sized appropriately
myShp.Width = [h:h].Width
myShp.Left = Target.Left - myShp.Width / 2 + Drp * 2
End If
Set myShp = Nothing
End Sub</pre>

To access your worksheet module, right click on the sheet tab, and left-click view code. Now paste the procedure in the now opened module.

Hope this helps. Happy Holidays eh!

_________________
Cheers,<font size=+2><font color="red"> Nate<font color="blue"> Oliver</font></font></font>
This message was edited by NateO on 2002-12-21 20:49
 
Upvote 0
Thanks for the reply Nat
Thanks for the reply to the query I sent to the board . I attempted the procedure as you described it but had no success the test sheet I set up were as follows, range my drop down are in F1:F7 and the columns containing the data was H. I am running excel 97 (due to the my employer this can not be changed) is there some thing I have missed ???
Regards
Robert
 
Upvote 0
Howdy Robert, I wrote this and tested it in xl 2000, but I will have a look in '97, I believe it will work.

Did you make sure to get the code in the correct worksheet module as described above?

Change [f1,c7] to [f1:f7]

Do you have other form drop downs in your worksheet? Depending on the order you created them, you may need to change the name to 2, 3, etc...

_________________
Cheers,<font size=+2><font color="red"> Nate<font color="blue"> Oliver</font></font></font>
This message was edited by NateO on 2002-12-21 17:14
 
Upvote 0
Howdy Robert, do you mind my asking what you think of Bazza? :biggrin:

I did test this in Excel '97. It turns out that I'm not smart enough to comment on the vertical aspect of the click button (there's nothing in the code which should prompt it to shift (yes-no?)). But otherwise, this is a fully functional approach:<pre>
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim myShp As Shape, Drp As Single
On Error Resume Next
'cells holding drop downs
If Intersect(Target, [f1:f7]) Is Nothing Then Exit Sub
If Target.Validation.Type = xlValidateList Then
Set myShp = ActiveSheet.Shapes("Drop Down 1")
Drp = myShp.Width - Target.Width
'Column holding list, sized appropriately
myShp.Width = [h:h].Width
myShp.Left = Target.Left - myShp.Width / 2 + Drp * 2
End If
Set myShp = Nothing
End Sub</pre>

Merry Christmas! :)

_________________
Cheers,<font size=+2><font color="red"> Nate<font color="blue"> Oliver</font></font></font>
This message was edited by NateO on 2002-12-21 20:52
 
Upvote 0
Thanks for the reply NateO
After a few changes I have my sheet operating now.
I can't say to much about Bazza as my son is a big Rangers fan, but if I was able to email you I would pass on a copy of the word doc containing Bazza's user setting for his computer running system

Windies Twa Thoosan’

The traditional “Start” button has been replaced with a more familiar term
Goan Yesel’ Bigman (and so on)

Thanks again for the help
Robert
 
Upvote 0
Increasing drop down validation box problem

Hello!

I was trying to implement the code underneath posted by Nate Oliver on 2002-12-21 to widen the list. The problem started at the 7th line, it seems that it doesn't want to set my validation box to myshp. Any ideas? I use Excel 97.

Thanks a lot.

<pre>
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim myShp As Shape, Drp As Single
On Error Resume Next
'cells holding drop downs
If Intersect(Target, [f1:f7]) Is Nothing Then Exit Sub
If Target.Validation.Type = xlValidateList Then
Set myShp = ActiveSheet.Shapes("Drop Down 1")
Drp = myShp.Width - Target.Width
'Column holding list, sized appropriately
myShp.Width = [h:h].Width
myShp.Left = Target.Left - myShp.Width / 2 + Drp * 2
End If
Set myShp = Nothing
End Sub</pre>

Adrian
 
Upvote 0

Forum statistics

Threads
1,215,353
Messages
6,124,458
Members
449,161
Latest member
NHOJ

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top