kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
Hi all,
I have this code which used to verify a value from a range of cells and that of my input. It used to work until yesterday when I did a few updates. I get the else alert for any item I feed the input box, except I feed it with the first item in the range – that is cell B4, where I get the match. Can someone tell me what I am doing wrongly?
Thanks in advance
I have this code which used to verify a value from a range of cells and that of my input. It used to work until yesterday when I did a few updates. I get the else alert for any item I feed the input box, except I feed it with the first item in the range – that is cell B4, where I get the match. Can someone tell me what I am doing wrongly?
Code:
Private MyCell As Range
Private MyInput As Variant, result&
While result = 10
MyInput = Application.InputBox("Enter the item name", "")
If MyInput = False Or MyInput = "" Then Exit Sub
MyInput = Replace(UCase(Trim(MyInput)), " ", "")
For Each MyCell In [B4:B18]
If MyInput = MyCell Then
MsgBox "My Input is " & MyInput & " , MyCell is " & MyCell
result = 0
Exit For
Else
MsgBox "My Input is " & MyInput & " , MyCell is " & MyCell
result = 10
Exit For
End If
Next MyCell
Wend
Thanks in advance