kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
I am using this code to capture two events “Enter” and “Change” textbox data. So when there is a change in both variables, I want to use the “Enter” variable to locate the ID of that item. The reason being that I will change that item with the “Change” variable. I observed I can’t change it since the location is same. So I tried using some of the tricks I know so far but the VBE is just laughing at me.
What is it that I am doing wrongly?
Thanks
What is it that I am doing wrongly?
Thanks
Code:
Option Explicit
Dim EnterValue As Variant
Dim NameID As Variant
Dim ChangeValue As Variant
Dim SName As Variant
Private Sub Rw2_Change()
Rw2 = UCase(Rw2)
ChangeValue = Rw2.Text
End Sub
Private Sub Rw2_Enter()
EnterValue = Rw2.Text
End Sub
Private Sub CmdCompareNameChange_Click()
With Sheet1
If Trim(EnterValue) = Trim(ChangeValue) Then
MsgBox "Match " & EnterValue & " , " & ChangeValue
Else
For Each SName In .[C4:C404]
For Each NameID In .[B4:B404]
If StName = EnterValue Then
NameID = SName.Offset(0, -1)
'NameID.Offset(0, 1) = ChangeValue
NameID.Offset(0, 1).Interior.ColorIndex = 37
MsgBox "Not Match " & EnterValue & " , " & ChangeValue & " , " '& NameID.Offset(0, 1).Value
Exit For
End If
Next NameID
Next SName
End If
End With
End Sub