PDA

View Full Version : Format Specific Rows



BENSON
08-28-2007, 06:25 AM
I have a spread sheet that has data across five colums.(A-E) .Colum A contains the ref code of the amounts shown in the other colums. eg:

KMI07865 6 7 8 2

is it posible to write a macro that will place a border around all the cells in the rows that begin with a KMI ref number.The amount of rows is varible.

Many Thanks

Bob Phillips
08-28-2007, 06:50 AM
Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long, j As Long
Dim iLastRow As Long
With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 1 To iLastRow 'iLastRow to 1 Step -1
If .Cells(i, "A").Value Like "KMI*" Then
For j = 1 To .Cells(i, .Columns.Count).End(xlToLeft).Column
.Cells(i, j).BorderAround Weight:=xlMedium
Next j
End If
Next i
End With

End Sub

BENSON
08-29-2007, 12:32 AM
Many Thanks xLD your formula worked fine.I know its a big ask but ,could you help with the following:
On the same spread sheet there are some merged cells,for example

A25:B26 (the ref code is placed in these 4 merged cells)
C25:I26 ( the description is placed in these 14 merged cells)
The umerged cells K26:Y26 contain the amount of specific items.Is it possible to format these cells with a border ?

Thank you again for your time