Make Dropdown List Temporarily Wider & Same Width for Multiple Col

G

Guest

Hi,
How do I modify the following macro from
http://www.contextures.com/xlDataVal08.html#Wider to make the dropdown list
temporarily wider for say COLUMNS BETWEEN 1 and 10, without having to specify
columns individually, e.g. Target.Column = 1, Target.Column = 2, etc.

Is there some sort of BETWEEN COMMAND I can use?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Column = 4 Then
Target.Columns.ColumnWidth = 20
Else
Columns(4).ColumnWidth = 5
End If
End Sub
 
B

Bob Phillips

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const WS_RANGE As String = "A:E" '<======= change to suit
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
Target.Columns.ColumnWidth = 20
Else
Columns(4).ColumnWidth = 5
End If
End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

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

Top