Data validation: wider window on 14 columns

J

Jim C

I need 14 columns to temporarily expand so a data validation window can be
read.

Can the following solution from
http://www.contextures.on.ca/xlDataVal08.html#Wider be used on multiple
columns?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Column = 37 Then
Target.Columns.ColumnWidth = 10
Else
Columns(37).ColumnWidth = 5
End If
End Sub
 
D

Dave Peterson

Maybe something like:

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim myRng As Range

If Target.Count > 1 Then Exit Sub

'adjust the range to what you want
Set myRng = Me.Range("a:b,x:y,d1:d5")

'fix all the columns
myRng.EntireColumn.ColumnWidth = 5

If Intersect(Target, myRng) Is Nothing Then
'do nothing
Else
'adjust that single column
Target.EntireColumn.ColumnWidth = 10
End If
End Sub
 
J

Jim C

It worked great! Is there any way to eliminate the "blinking" in the
worksheet as the cursor moves to another cell?
--
Jim C


Dave Peterson said:
Maybe something like:

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim myRng As Range

If Target.Count > 1 Then Exit Sub

'adjust the range to what you want
Set myRng = Me.Range("a:b,x:y,d1:d5")

'fix all the columns
myRng.EntireColumn.ColumnWidth = 5

If Intersect(Target, myRng) Is Nothing Then
'do nothing
Else
'adjust that single column
Target.EntireColumn.ColumnWidth = 10
End If
End Sub
 
D

Dave Peterson

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim myRng As Range

If Target.Count > 1 Then Exit Sub

'adjust the range to what you want
Set myRng = Me.Range("a:b,x:y,d1:d5")

application.screenupdating = false '<-- added

'fix all the columns
myRng.EntireColumn.ColumnWidth = 5

If Intersect(Target, myRng) Is Nothing Then
'do nothing
Else
'adjust that single column
Target.EntireColumn.ColumnWidth = 10
End If

application.screenupdating = True '<-- added

End Sub

Jim said:
It worked great! Is there any way to eliminate the "blinking" in the
worksheet as the cursor moves to another cell?
 

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