Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format the text in Column 3 which is in Column 1 for each row.

Status
Not open for further replies.

Poduska

Technical User
Dec 3, 2002
108
US
I have many rows, column A and Column B each have detailed SQL statements which are concatanated into one statment in Column C. We would like to be able to Bold the part of Column C which was in Column A. There are hundreds of rows, could be done but....

I found some code in in thread68-538417 which works but only for the prompted text and then the entire worksheet.

Anyone care to see if this can be modified? I have never used VB in Excel.
Here is the sample I found if it offers inspiration.
Code:
Sub ColText()

Dim i As Long
Dim j As Integer
Dim k As Integer
Dim num As Long
Dim ans As String
Dim str As String

ans = InputBox("What string do you want to find")
i = Application.WorksheetFunction.CountIf(ActiveSheet.UsedRange, "*" & ans & "*")
j = Len(ans)

Application.ScreenUpdating = False
For num = 1 To i
     
      Cells.Find(What:=ans, After:=ActiveCell, LookIn:=xlValues, LookAt:= _
        xlPart, MatchCase:=False, SearchFormat:=False).Activate
   k = Application.WorksheetFunction.Find(ans, ActiveCell)
        
   With ActiveCell.Characters(Start:=k, Length:=j).Font
        .ColorIndex = 4
   End With
        
   Cells.FindNext(After:=ActiveCell).Activate
Next num

End Sub
 
Provided that Column C = Column A & Column B, here a starting point:
ActiveSheet.Cells(lngRow, 3).Characters(1, Len(ActiveSheet.Cells(lngRow, 1).Text)).Font.ColorIndex = 4

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top