View Single Post
 
Old 09-17-2015, 01:36 PM
charlesdh charlesdh is offline Windows 7 32bit Office 2010 32bit
Expert
 
Join Date: Apr 2014
Location: Mississippi
Posts: 382
charlesdh is on a distinguished road
Default

Ni,

Not knowing how you have your file set this code will be limited.
It will find the text you specified and bold it. It will then go to the next column in the same row as the specified text and if there is data it will underline the cell "Bold" it will do this for 4 columns only.
Paste the code to a module and test it.
Test on copy data only.

Code:
Sub Find_Specific_String()
Dim varFound As Variant, varSearch As Variant
Dim strAddress As String, intPos As Integer
Dim i As Long
varSearch = "Total Revenue and Other Income"
Set varFound = Cells.Find(varSearch, LookIn:=xlValues, LookAt:=xlPart)

If Not varFound Is Nothing Then
    With varFound
    intPos = InStr(intPos + 1, .Value, varSearch, vbTextCompare)
        If intPos Then
            .Characters(Start:=intPos, Length:=Len(varSearch)).Font.FontStyle = "Bold"
            For i = 1 To 4 '' this will only loop  4 columns
                If Cells(varFound.Row, 2).Text <> "" Then
                With Cells(varFound.Row, 2).Borders(xlEdgeBottom)
                    .LineStyle = xlContinuous
                    .Weight = xlMedium
                    .ColorIndex = 1
                End With
                End If
            Next i
        End If
    End With
End If
End Sub
You need to provide a file that we can work with in order to make corrections to the code supplied.

Charles
Reply With Quote