Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Excel Range.Replace - Supress Not found message?

Excel Range.Replace - Supress Not found message?

Excel Range.Replace - Supress Not found message?

I am automating Excel and the Excel Applciation is not visible.

XLRange is an Excel Range object.  "|hash|"  does not always occur which produces a message that I would rather surpress...  "Microsoft Excel Cannot find any data to replace.  Check if you search formatting and criteria are defined correctly. If you are sure that matching data exists in this workbook, it may be on a protected sheet. Excel cannot replace data on a protected worksheet."


XLRange.Replace What:="|hash|", Replacement:="#", LookAt:=xlPart, _
            SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _

What if anything can I do to surpress the message?


RE: Excel Range.Replace - Supress Not found message?


FIRST do a Find, like...


dim rFound as range

set rFound = XLRange.Find("|hash|")

if not rFound is nothing then
  'now do your replace
end if


glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Excel Range.Replace - Supress Not found message?

I am not that familar with the Excel Object models...  I suspected there was a way to turn off messages.  Thanks PHV!

RE: Excel Range.Replace - Supress Not found message?

I did figure out the second issue or the linked thread above.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close