PDA

View Full Version : Can I combine these into 4 lines?



Djblois
03-27-2007, 08:20 AM
Range("A:A").Find(What:="Subtotal Operating").Select
Range(Selection, Selection.End(xlToRight)).Select
With Range(Selection, Selection.End(xlToRight)).Select
.Font.Bold = True
.Interior.ColorIndex = 6
End With

mvidas
03-27-2007, 08:36 AM
Sure, but why restrict it to 4 lines?
Dim CLL As Range
Set CLL = Columns("A").Find("Subtotal Operating")
Range(CLL, CLL.End(xlToRight).End(xlToRight)).Font.Bold = True
Range(CLL, CLL.End(xlToRight).End(xlToRight)).Interior.ColorIndex = 6
Or, if you know the number of columns you want to include (I put 13 here):With Columns("A").Find("Subtotal Operating").Resize(1, 13)
.Font.Bold = True
.Interior.ColorIndex = 6
End WithLastly, if you want to do this to every instance of "Subtotal Operating" in column A (though more than 4 lines):Dim CLL As Range, CLL2 As Range
Set CLL = Columns("A").Find("Subtotal Operating")
Set CLL2 = CLL
Do
CLL.Resize(1, 13).Font.Bold = True
CLL.Resize(1, 13).Interior.ColorIndex = 6
Set CLL = Columns("A").FindNext(CLL)
Loop Until CLL2.Address = CLL.AddressMatt

mdmackillop
03-27-2007, 08:39 AM
Dim c As Range
Set c = Range("A:A").Find(What:="Subtotal Operating")
With Range(c, c.End(xlToRight))
.Font.Bold = True
.Interior.ColorIndex = 6
End With