How to i check the textbox value to the cells value

whcmelvin

Board Regular
Joined
Jul 27, 2011
Messages
82
When i run the Code below, they will keep prompting me that my email does not exist whenever i click 1 letter in. how do i make it prompt me only after i finished typing in the textbox?

Code:
Private Sub EmailForget_Change()
Dim r1 As Range
Dim n1 As Long
Dim NextRow1 As Long

    Application.ScreenUpdating = False
    
    Sheets("Login Details").Select
    
    NextRow1 = Application.WorksheetFunction.CountA(Range("A:A")) + 1
    Set r1 = Range(Cells(2, 1), Cells(NextRow1, 1))
    
    For n1 = 2 To r1.Rows.Count
        If Trim(EmailForget.Value) = Trim(Cells(n1, 1).Value) Then
            SecurityQnForget.Value = Trim(Cells(n1, 10).Value)

        End If
        
    Next n1

            If Trim(EmailForget.Value) <> Trim(Cells(n1, 1).Value) Then
                        MsgBox "Your email does not exist.", vbCritical
        End If
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Why don't you test for Enter instead? Like:
Code:
Private Sub EmailForget_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    If KeyCode <> 13 Then Exit Sub

' ... the rest of your code ...
        
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,750
Members
452,940
Latest member
rootytrip

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top