I have the below code in ThisWorkbook, the only problem is, with worksheet protection enabled, it generates a runtime error. I know I can update the protection to allow this but I only want the column to be widened while a specific row is selected (either row 3 or 4 depending on the sheet). Once that row is not active anymore, I want the column width to go back to four. Can this code be modified to allow for this?
Thanks,
Don
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If ActiveSheet.Name = "PRIMARY MECHANICAL" Or ActiveSheet.Name = "RESERVE MECHANICAL" Then
If Target.Row = 4 And Target.Column > 1 Then
Target.ColumnWidth = 15
Else
Range("B4:BK4").ColumnWidth = 4
End If
ElseIf ActiveSheet.Name = "PRIMARY EQUIPMENT" Or ActiveSheet.Name = "RESERVE EQUIPMENT" Then
If Target.Row = 3 And Target.Column > 1 Then
Target.ColumnWidth = 15
Else
Range("B3:BK3").ColumnWidth = 4
End If
End If
End Sub
Station 101 Vehicle and Gear Checks - Sample.xlsm
Bookmarks