I'm hoping someone can help me out with this one.
Sub FormatColumns()
dim sht as Worksheet
dim RollWorkbook as Workbook
dim EncumbranceColumn as long
dim Merchandise Column as long
For Each sht In RollWorkbook.Sheets
On Error GoTo HANDLER_1:
EncumbranceColumn = Cells.Find(What:="*ENCUMBRANCE*", _
After:=Cells(Rows.Count, Columns.Count), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Column
If EncumbranceColumn > 0 Then
Columns(EncumbranceColumn).NumberFormat = "$#,##0.00"
End If
HANDLER_1:
Next sht
For Each sht In RollWorkbook.Sheets
On Error GoTo HANDLER_2:
MerchandiseColumn = Cells.Find(What:="*MERCHANDISE*", _
After:=Cells(Rows.Count, Columns.Count), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Column
If MerchandiseColumn > 0 Then
Columns(MerchandiseColumn).NumberFormat = "$#,##0.00"
End If
HANDLER_2:
Next sht
RollWorkbook.Activate
End Sub
This keeps failing on me with "RTE '91': Object variable or With block variable not set. It happens as soon as the second cells.find (MerchandiseColumn) doesn't find what it's looking for on the very first sheet. For the life of me I haven't been able to figure out what the deal is and why my On Error isn't working. Any help would be seriously appreciated.
Justin
Bookmarks