Trying to search the column with 'TOC' as the header and alter the size, which works fine. The problem I'm having is I no longer want to have an error message pop up if the cells are empty or contain other values - I just want it to ignore and move on to the next task. Thanks in advance of your help.
Example spreadsheet attached sheet 1 with TOC column and sheet 2 without. Will load shortly as Safari not letting me load!
Sub TOC_width()
Dim rng As Range, w As Long
Set rng = Rows(1).Find(What:="TOC", LookAt:=xlWhole, LookIn:=xlFormulas)
If rng Is Nothing Then
MsgBox "TOC", vbCritical
Else
Select Case rng.Column
'Case = column number i.e. A=1, B=2 etc...
'w = column width
Case 1
w = 3
Case 2
w = 3
Case 3
w = 3
Case Else
w = rng.ColumnWidth
End Select
rng.ColumnWidth = w
End If
End Sub
Bookmarks