ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   On error resume next and cdate problem (https://www.excelbanter.com/excel-programming/337616-error-resume-next-cdate-problem.html)

[email protected]

On error resume next and cdate problem
 
Hello,
I'm having a problem with the code stopping at the (Range("Bid_Date") =
CDate(TextBox5)) line. My code was working fine until I added the lines
for the description check which makes sure the user doesn't add a
description in the textbox of the userform that has been previously
entered. I think the problem may be with the error goto & error resume
next statement. Does anybody have any insight on this?
Thanks,
Darrell


'CHECKS IF DESCRIPTION HAS BEEN PREVIOUSLY ENTERED
'...Added description check

On Error GoTo 100
If Cells.Find(What:=i, After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=ylNext,
MatchCase:= _
True).Activate = True Then
MsgBox "The description you entered has been entered on a previous
job."
GoTo 200
End If

100

Range("L3").Select
Cells.Find(What:=n, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=ylNext,
MatchCase:= _
False).Activate


Selection.Offset(0, -10).Select



response = MsgBox("Do you want to add this information to another line
for existing job# " & j & "-" & Format(k, "000") & "?", vbYesNo)
If response = vbYes Then

Unload Existing_Task

Range("EII_Number") = CInt(TextBox1)
Range("Seq_Number") = CInt(TextBox2)
Range("Customer") = TextBox3
Range("Solicitation") = TextBox4

On Error Resume Next
MsgBox Existing_Task.TextBox5
'...Stops at the following line
Range("Bid_Date") = CDate(TextBox5)
If CDate(TextBox5) = False Then
Range("Bid_Date") = TextBox5
End If


Tom Ogilvy

On error resume next and cdate problem
 
if your find statment does not find a duplicate entry, then it will try to
activate nothing. That will raise an error.

Dim rng as Range
set rng = Cells.Find()
if not rng is nothing then
rng.activate
msgbox "something"
else
' no duplicate found
End if

--
Regards,
Tom Ogilvy


wrote in message
ups.com...
Hello,
I'm having a problem with the code stopping at the (Range("Bid_Date") =
CDate(TextBox5)) line. My code was working fine until I added the lines
for the description check which makes sure the user doesn't add a
description in the textbox of the userform that has been previously
entered. I think the problem may be with the error goto & error resume
next statement. Does anybody have any insight on this?
Thanks,
Darrell


'CHECKS IF DESCRIPTION HAS BEEN PREVIOUSLY ENTERED
'...Added description check

On Error GoTo 100
If Cells.Find(What:=i, After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=ylNext,
MatchCase:= _
True).Activate = True Then
MsgBox "The description you entered has been entered on a previous
job."
GoTo 200
End If

100

Range("L3").Select
Cells.Find(What:=n, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=ylNext,
MatchCase:= _
False).Activate


Selection.Offset(0, -10).Select



response = MsgBox("Do you want to add this information to another line
for existing job# " & j & "-" & Format(k, "000") & "?", vbYesNo)
If response = vbYes Then

Unload Existing_Task

Range("EII_Number") = CInt(TextBox1)
Range("Seq_Number") = CInt(TextBox2)
Range("Customer") = TextBox3
Range("Solicitation") = TextBox4

On Error Resume Next
MsgBox Existing_Task.TextBox5
'...Stops at the following line
Range("Bid_Date") = CDate(TextBox5)
If CDate(TextBox5) = False Then
Range("Bid_Date") = TextBox5
End If




[email protected]

On error resume next and cdate problem
 
I appreciate it Tom. That fixed it.
Thanks,
Darrell



All times are GMT +1. The time now is 02:04 AM.

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