ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   error message 91 when entering wrong data (https://www.excelbanter.com/excel-programming/361409-error-message-91-when-entering-wrong-data.html)

eyesonly1965[_15_]

error message 91 when entering wrong data
 

the following code is for updating a textbox on my form, but when
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 wil
return a specific value to my second textbox.

can anybody help me

--
eyesonly196
-----------------------------------------------------------------------
eyesonly1965's Profile: http://www.excelforum.com/member.php...fo&userid=3419
View this thread: http://www.excelforum.com/showthread.php?threadid=54180


Bob Phillips[_6_]

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"
wrote in message
news:eyesonly1965.27r34m_1147531201.5328@excelforu m-nospam.com...

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




eyesonly1965[_16_]

error message 91 when entering wrong data
 

thank you it does excactly what i want


--
eyesonly1965
------------------------------------------------------------------------
eyesonly1965's Profile: http://www.excelforum.com/member.php...o&userid=34199
View this thread: http://www.excelforum.com/showthread...hreadid=541809



All times are GMT +1. The time now is 01:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com