Results 1 to 4 of 4
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Search/Replace Error Code (03)

    If I select a column and then Ctl-H the find and replace dialog box appears. If I enter text (that is not in the column selected ) in the "Find What" field and enter some other text in the "Replace With" field and then click on replace all. An error box appears indicating that MS can not find anything to replace.

    Is it possible to capture this error message via VBA?

    Thanks,
    John

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Search/Replace Error Code (03)

    Not as far as I know. Can you tell us what you want to accomplish?

  3. #3
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Search/Replace Error Code (03)

    Hans,

    I would like to be able to determine if the text was not found in the column. I have used the macro recorder to generate the code and it works if the "Find What" text is in the column. If I change the "Find What" text to something else that I know is not in the column and rerun the code, the code works. Well let's just say the code does not fail because the "Find What" text can not be found.

    John

  4. #4
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Search/Replace Error Code (03)

    Hans,

    This is what I came up with using a different approach. The end result is what I need.

    Sub testit()
    var1 = "My Text"
    With Worksheets("Sheet1").Columns("D")
    Set c = .Find("" & var1 & "", LookIn:=xlValues)
    If c Is Nothing Then
    MsgBox "Not Listed-Nothing"
    End
    ElseIf c <> "" & var1 & "" Then
    MsgBox "Not Listed"
    End
    End If

    If c = "" & var1 & "" Then
    MsgBox "Yeah it worked"
    End If

    End With
    End Sub



    Thanks,
    John

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •