INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

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!

Join Tek-Tips
*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.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Excel Range.Replace - Supress Not found message?

Excel Range.Replace - Supress Not found message?

(OP)
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."

CODE

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

What if anything can I do to surpress the message?

Thanks.

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



hi,

FIRST do a Find, like...

CODE

dim rFound as range

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

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

Skip,

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

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

(OP)
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?

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

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