Simplfy if statement

J

Jim

How would one simplify the following:

If Target.Count > 1 Then GoTo errHandler

If Target.Column = 7 Then
Target.Columns.ColumnWidth = 15
Else
Columns(7).ColumnWidth = 8

If Target.Column = 8 Then
Target.Columns.ColumnWidth = 25
Else
Columns(8).ColumnWidth = 15
End If

If Target.Column = 3 Then
Target.Columns.ColumnWidth = 10
Else
Columns(3).ColumnWidth = 8
End If

If Target.Column = 4 Then
Target.Columns.ColumnWidth = 10
Else
Columns(4).ColumnWidth = 8
End If

End If


Cheers
 
R

RichardSchollar

Hi Jim

Perhaps:

If Target.Count > 1 Then GoTo errHandler
Range("C1,D1,G1").ColumnWidth = 8: Range("h1").ColumnWidth = 15
Select Case Target.Column
Case 3, 4
Columns(Target.Column).ColumnWidth = 10
Case 7
Columns(Target.Column).ColumnWidth = 15
Case 8
Columns(Target.Column).ColumnWidth = 25
Case Else
End Select

Richard
 
J

Jim

Thanks Reichard,

It seems so simple but constantly reminds me of how much I have to learn -
or adopt from the truly learned.

Cheers
Jim
 

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