haradaindustryofamerica
asked on
Excel Data Validation List Sizing and Selection
Please see attached spreadsheet.
I would like the data validation list show the entire selection - Example: AL - ALABAMA.
But after selection only show the initials - Example after selection form list : AL
I also want the column to only be as wide as the selected initials, so selection drop down list is large and shows full selection but column still only as wide as the initials of the state.
Thanks
C--Users-dlehman-Desktop-Test-Sheet.xlsx
I would like the data validation list show the entire selection - Example: AL - ALABAMA.
But after selection only show the initials - Example after selection form list : AL
I also want the column to only be as wide as the selected initials, so selection drop down list is large and shows full selection but column still only as wide as the initials of the state.
Thanks
C--Users-dlehman-Desktop-Test-Sheet.xlsx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks MArtin - Been awhile but I remembered.
You'll note that the width of the column is being limited by the width of "State" so if you truly want it to be the width of the abbreviation you could change the heading to "ST" or change line 5 to Columns("B").ColumnWidth = 2.45.
In any case you're welcome and I'm glad I was able to help.
In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
In any case you're welcome and I'm glad I was able to help.
In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
ASKER
Hi Martin,
I have used the lines in a new sheet (see attached) but for some reason it is not working properly for resizing the column as well as the drop down list.
Could you please take a look at the attached sheet the "Type" column and let me know what I am doing wrong?
Thanks
C--Users-dlehman-Desktop-Part-Order-Form
I have used the lines in a new sheet (see attached) but for some reason it is not working properly for resizing the column as well as the drop down list.
Could you please take a look at the attached sheet the "Type" column and let me know what I am doing wrong?
Thanks
C--Users-dlehman-Desktop-Part-Order-Form
The drop-down list worked for me but it was resizing the wrong column.
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(ActiveCell, Range("C12:C21")) Is Nothing Then
Application.EnableEvents = False
ActiveCell = Left(ActiveCell, 2)
' Columns("B:B").EntireColumn.AutoFit
Columns("C:C").EntireColumn.AutoFit
Application.EnableEvents = True
End If
End Sub
ASKER
Martin,
Great thanks, that works perfect now for me before saving the file.
After I save the file and then re-open the file to add more data, the data validation list sizing does not work properly. Please see two screen shot attachments of before and after save.
C--Users-dlehman-Desktop-After-save---Re
C--Users-dlehman-Desktop-Before-Saving-a
Great thanks, that works perfect now for me before saving the file.
After I save the file and then re-open the file to add more data, the data validation list sizing does not work properly. Please see two screen shot attachments of before and after save.
C--Users-dlehman-Desktop-After-save---Re
C--Users-dlehman-Desktop-Before-Saving-a
I think the best solution is to not manipulate the width of the Type column at all but rather just set it to about 17 and keep it static. Other than that I see only two other choices:
1) Add this code to the workbook.
2) Use the code in my Magical Floating ActiveX Control article to float a wider combobox on top of the dropdown list. I could help you with that if you want, but I'd appreciate it if you'd open a new question for that.
1) Add this code to the workbook.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(ActiveCell, Range("C12:C21")) Is Nothing Then
Target.Columns.ColumnWidth = 15
End If
End Sub
There a small problem with this approach and that is if you select a Type and then try to change the Type without first moving off the cell, the cell won't expand.2) Use the code in my Magical Floating ActiveX Control article to float a wider combobox on top of the dropdown list. I could help you with that if you want, but I'd appreciate it if you'd open a new question for that.
ASKER
Holy mackerel that is way past my experience level, I will open a ticket for your assistance!
Thanks Martin.
Thanks Martin.
ASKER
Martin - New question posted.
Question title
- Magical Floating ActiveX Control fro Excel Data Validation List
Question title
- Magical Floating ActiveX Control fro Excel Data Validation List
ASKER