Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
XP now has the ability to do a find & replace based on
formatting, but i ran across an issue. If I type the word accountant in cell A1 and "accountants are fun" in cell A2, do a find and replace for the word accountant that will bold it. In cell a2 it will bold the entire cell instead of just the word accountant, is there a way around this if you just want the text and not the entire cell formatted? Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
One way though can take a little while if a lot of text:-
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) Cells.Find(what:=ans, After:=ActiveCell, LookIn:=xlValues, LookAt:= _ xlPart, MatchCase:=False).Activate For num = 1 To i k = Application.WorksheetFunction.Find(ans, ActiveCell) With ActiveCell.Characters(Start:=k, Length:=j).Font .ColorIndex = 3 .Bold = True End With Cells.FindNext(After:=ActiveCell).Activate Next num End Sub If you don't want the colour then comment out the .ColorIndex = 3 line at the end -- Regards Ken....................... Microsoft MVP - Excel Sys Spec - Win XP Pro / XL 97/00/02/03 ---------------------------------------------------------------------------- It's easier to beg forgiveness than ask permission :-) ---------------------------------------------------------------------------- "Jewel" wrote in message ... XP now has the ability to do a find & replace based on formatting, but i ran across an issue. If I type the word accountant in cell A1 and "accountants are fun" in cell A2, do a find and replace for the word accountant that will bold it. In cell a2 it will bold the entire cell instead of just the word accountant, is there a way around this if you just want the text and not the entire cell formatted? Thanks --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.668 / Virus Database: 430 - Release Date: 24/04/2004 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Note though that this will only do one instance of the data in any one cell.
-- Regards Ken....................... Microsoft MVP - Excel Sys Spec - Win XP Pro / XL 97/00/02/03 ---------------------------------------------------------------------------- It's easier to beg forgiveness than ask permission :-) ---------------------------------------------------------------------------- "Ken Wright" wrote in message ... One way though can take a little while if a lot of text:- 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) Cells.Find(what:=ans, After:=ActiveCell, LookIn:=xlValues, LookAt:= _ xlPart, MatchCase:=False).Activate For num = 1 To i k = Application.WorksheetFunction.Find(ans, ActiveCell) With ActiveCell.Characters(Start:=k, Length:=j).Font .ColorIndex = 3 .Bold = True End With Cells.FindNext(After:=ActiveCell).Activate Next num End Sub If you don't want the colour then comment out the .ColorIndex = 3 line at the end -- Regards Ken....................... Microsoft MVP - Excel Sys Spec - Win XP Pro / XL 97/00/02/03 ---------------------------------------------------------------------------- It's easier to beg forgiveness than ask permission :-) ---------------------------------------------------------------------------- "Jewel" wrote in message ... XP now has the ability to do a find & replace based on formatting, but i ran across an issue. If I type the word accountant in cell A1 and "accountants are fun" in cell A2, do a find and replace for the word accountant that will bold it. In cell a2 it will bold the entire cell instead of just the word accountant, is there a way around this if you just want the text and not the entire cell formatted? Thanks --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.668 / Virus Database: 430 - Release Date: 24/04/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.668 / Virus Database: 430 - Release Date: 24/04/2004 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Find & Replace: find part cell, replace whole cell | Excel Worksheet Functions | |||
Find and Replace - Replace with Blank Space | Excel Discussion (Misc queries) | |||
Copy contents of Find (Find and Replace) | Excel Discussion (Misc queries) | |||
where to put results of find operation in find and replace functio | Excel Worksheet Functions | |||
find and replace - replace data in rows to separated by commas | Excel Worksheet Functions |