david graham
Active Member
- Joined
- Dec 6, 2007
- Messages
- 345
The code below sorts a list & then formats only the visible rows. This there a line i can add that will keep it from trying to format when there are no visible rows in the selection?
will "If Not rng Is Nothing Then" work & if so where do i need to put it?
will "If Not rng Is Nothing Then" work & if so where do i need to put it?
Code:
'FORMAT LABOR ITEMS
Sheets("LIST").Select
Range("R1").Select
Selection.AutoFilter Field:=1, Criteria1:="6"
Range("b1").Select
Set r = ThisWorkbook.Worksheets("LIST").Range("B14:b30000").SpecialCells(xlCellTypeVisible)
With r.Interior
.ColorIndex = 2
.Pattern = xlSolid
r.HorizontalAlignment = xlLeft
r.VerticalAlignment = xlTop
r.WrapText = True
r.Font.ColorIndex = 2
r.RowHeight = 30.75
End With
Set r = ThisWorkbook.Worksheets("LIST").Range("C14:C30000").SpecialCells(xlCellTypeVisible)
With r.Interior
.ColorIndex = 2
.Pattern = xlSolid
r.HorizontalAlignment = xlLeft
r.VerticalAlignment = xlTop
r.WrapText = True
r.Font.ColorIndex = 1
r.RowHeight = 30.75
End With
Set r = ThisWorkbook.Worksheets("LIST").Range("D14:E30000").SpecialCells(xlCellTypeVisible)
With r.Interior
.ColorIndex = 15
.Pattern = xlSolid
r.HorizontalAlignment = xlCenter
r.VerticalAlignment = xlCenter
r.WrapText = True
r.Font.ColorIndex = 1
r.RowHeight = 30.75
End With