Make Validation List Wider - Excel 2003

  • Thread starter Thread starter cmarion
  • Start date Start date
C

cmarion

I found the following post from 2006 and the code works great, but it is for
one column, how do I alter the code for columns C through AX so the temporary
widening happens in each column?

"You cannot word-wrap a list for DV.

What you can do is use event code to make the list wider when you click on the
drop-down.

See Debra Dalgeish's site for code.

http://www.contextures.on.ca/xlDataVal08.html#Wider"
 
You can change the target columns:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Column >= 3 And Target.Column <= 50 Then
Target.Columns.ColumnWidth = 20
Else
Columns(4).ColumnWidth = 5
End If
End Sub
 
This works for expanding the column width, but does not return the column to
the smaller size when no longer selected.

Thank you.
 
This will reset all the affected columns to the same width.
If you need them different widths you could specify in the code.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Columns("C:AX").ColumnWidth = 5
If Target.Column >= 3 And Target.Column <= 50 Then
Target.Columns.ColumnWidth = 20
Else
Columns("C:AX").ColumnWidth = 5
End If
End Sub
 
Wonderful, thank you for your help.

Debra Dalgleish said:
This will reset all the affected columns to the same width.
If you need them different widths you could specify in the code.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Columns("C:AX").ColumnWidth = 5
If Target.Column >= 3 And Target.Column <= 50 Then
Target.Columns.ColumnWidth = 20
Else
Columns("C:AX").ColumnWidth = 5
End If
End Sub




--
Debra Dalgleish
Contextures
www.contextures.com/tiptech.html
Blog: http://blog.contextures.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top