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

Hi,
For performing Search/Replace in Comments of an Excel Sheet, I was abl
to come up with something like:

Code
-------------------

Sub comments_replace()

Dim FoundCell As Range
Dim FindWhat As String
Dim WithWhat As String

FindWhat = "User"
WithWhat = "XXX"

Do
Set FoundCell = ActiveSheet.Cells.Find(What:=FindWhat, _
After:=ActiveCell, _
LookIn:=xlComments, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)

If FoundCell Is Nothing Then
Exit Do
Else
FoundCell.Comment.Text _
Application.Substitute(FoundCell.Comment.Text, _
FindWhat, WithWhat)
End If
Loop

End Sub

-------------------


However, this code works well when i have "MatchCase:=True". If th
"Match Case" option is set to true, the code gives me an error at th
line "If FoundCell Is Nothing Then". My MS Excel freezes and stop
responding.

Please can someone help.
Thanks,
Lonel

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Search/Replace in Comments in Excel

Don't know really, but try

Dim FoundCell as Object


---
Message posted from http://www.ExcelForum.com/

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Search/Replace in Comments in Excel

Hi Brian,
I tried using this, but it didnt work.
Thanks,
Lonel

--
Message posted from http://www.ExcelForum.com

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
Search and replace help in Excel XAT Excel Discussion (Misc queries) 4 March 24th 08 05:02 PM
Replace data by VALUE or COMMENTS not availabel in Excel 2003 ??? MCP Excel Discussion (Misc queries) 6 December 19th 06 04:14 PM
Excel comments replace author Not_an_expert Excel Discussion (Misc queries) 2 March 29th 06 08:25 PM
How do I do a search and replace in a textbox in Excel? ToolQueen Excel Discussion (Misc queries) 0 June 27th 05 09:25 PM
Find and replace for comments in excel 2003 omprakash Excel Discussion (Misc queries) 1 January 28th 05 05:55 AM


All times are GMT +1. The time now is 07:47 AM.

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

About Us

"It's about Microsoft Excel"