Simplfy if statement
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 |
Simplfy if statement
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 On 30 Nov, 09:16, Jim wrote: 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 |
Simplfy if statement
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 "RichardSchollar" wrote: 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 On 30 Nov, 09:16, Jim wrote: 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 |
All times are GMT +1. The time now is 05:11 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com