Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Find & Replace in XP

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default Find & Replace in XP

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default Find & Replace in XP

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find & Replace: find part cell, replace whole cell katy Excel Worksheet Functions 3 April 3rd 23 01:20 PM
Find and Replace - Replace with Blank Space Studebaker Excel Discussion (Misc queries) 4 April 3rd 23 10:55 AM
Copy contents of Find (Find and Replace) rob_bob Excel Discussion (Misc queries) 0 March 26th 09 11:01 PM
where to put results of find operation in find and replace functio DEP Excel Worksheet Functions 5 November 15th 06 07:52 PM
find and replace - replace data in rows to separated by commas msdker Excel Worksheet Functions 1 April 15th 06 01:00 AM


All times are GMT +1. The time now is 01:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"