+ Reply to Thread
Results 1 to 3 of 3

error message 91 when entering wrong data

  1. #1
    Registered User
    Join Date
    05-07-2006
    Posts
    19

    error message 91 when entering wrong data

    the following code is for updating a textbox on my form, but when i enter data that is not in the list i get an error.

    Private Sub txtBestellingArtikelCode2_Change()

    ActiveWorkbook.Sheets("artikelen").Activate
    Cells.Find(What:=txtBestellingArtikelCode2.Value, After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
    xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
    , SearchFormat:=False).Activate
    txtBestellingArtikelOmschrijving2.Value = ActiveCell.Offset(0, 1).Value

    End Sub


    what i want if it is possible that when the data is not found it will return a specific value to my second textbox.

    can anybody help me?

  2. #2
    Bob Phillips
    Guest

    Re: error message 91 when entering wrong data

    Private Sub txtBestellingArtikelCode2_Change()
    Dim cell As Range
    ActiveWorkbook.Sheets("artikelen").Activate
    Set cell = Cells.Find(What:=txtBestellingArtikelCode2.Value, _
    After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, _
    SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, _
    MatchCase:=False, _
    SearchFormat:=False)
    If Not cell Is Nothing Then
    txtBestellingArtikelOmschrijving2.Value = _
    cell.Offset(0, 1).Value
    End If

    End Sub


    --

    HTH

    Bob Phillips

    (remove nothere from the email address if mailing direct)

    "eyesonly1965" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > the following code is for updating a textbox on my form, but when i
    > enter data that is not in the list i get an error.
    >
    > Private Sub txtBestellingArtikelCode2_Change()
    >
    > ActiveWorkbook.Sheets("artikelen").Activate
    > Cells.Find(What:=txtBestellingArtikelCode2.Value,
    > After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
    > xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
    > MatchCase:=False _
    > , SearchFormat:=False).Activate
    > txtBestellingArtikelOmschrijving2.Value = ActiveCell.Offset(0,
    > 1).Value
    >
    > End Sub
    >
    >
    > what i want if it is possible that when the data is not found it will
    > return a specific value to my second textbox.
    >
    > can anybody help me?
    >
    >
    > --
    > eyesonly1965
    > ------------------------------------------------------------------------
    > eyesonly1965's Profile:

    http://www.excelforum.com/member.php...o&userid=34199
    > View this thread: http://www.excelforum.com/showthread...hreadid=541809
    >




  3. #3
    Registered User
    Join Date
    05-07-2006
    Posts
    19

    Thumbs up thanx this works the way i want

    thank you it does excactly what i want

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1