Consulting

Results 1 to 3 of 3

Thread: Format Specific Rows

  1. #1
    VBAX Contributor
    Joined
    Dec 2006
    Posts
    193
    Location

    Format Specific Rows

    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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    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
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Contributor
    Joined
    Dec 2006
    Posts
    193
    Location
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •