Check VBA code to locate value in cell

Akw47

Board Regular
Joined
Nov 6, 2020
Messages
90
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello this is the current code I have

VBA Code:
Private Sub TextBox1_AfterUpdate()

Dim m As String
Dim rx As String
rx = Trim(TextBox1.Text)
lastrow = Worksheets("sheet1").Cells(rows.Count, 5).End(x1Up).Row

For i = 2 To lastrow
If Worksheets("sheet1").Cells(i, 1).Value = rx Then
TextBox2.Text = Worksheets("sheet1").Cells(i, 2).Value

If rx = (InStr(Me.TextBox1.Value, "/") > 0 Or InStr(Me.TextBox1.Value, ",") > 0) Then
m = MsgBox("Please confirm", vbYesNo, "Double Check")
        End If
    End If
End Sub

I want it such that if there is a "/" or "," along with the found value. A message box should pop out. Currently, there seems to be a error. Could you help me edit it?
 

Akw47

Board Regular
Joined
Nov 6, 2020
Messages
90
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Did you put 12345 in col A before the last row of data in col E?
i put 12345 / in col A. to test whether that function works. when i type 12345 in textbox
 

Some videos you may like

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
48,051
Office Version
  1. 365
Platform
  1. Windows
But is there data in col E below that value?
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
48,051
Office Version
  1. 365
Platform
  1. Windows
You also need to change this
VBA Code:
Dim rx As Double
 

Akw47

Board Regular
Joined
Nov 6, 2020
Messages
90
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
New.PNG
 

Watch MrExcel Video

Forum statistics

Threads
1,113,890
Messages
5,544,883
Members
410,643
Latest member
sng
Top