I am just new in excel VBA and I really need help about the code I am using .Any help is appreciated.
I have a VBA UserForm with a multiline Textbox. The user pastes a list of values into it. Then, those values will be checked comparing values in column A. Then, the compared output will be display into Textbox2 . It means if some values in Textbox1 are same with the values with Column A it will be display in Textbox2 . All values that are not existing in Column A that have in Textbox1 will not be included. The code I am using is working. But its output are those values that are not existing in Column A instead of the similar values.
Here's the code:
Private Sub CommandButton1_Click()
Dim TxRay As Variant
Dim Lpray As Variant
Dim oLp As Integer
Dim rng As Range
Dim R As Integer
Dim Ray As Variant
Dim Txt As String
Dim st As Integer
Dim n
TxRay = Split(Replace(TextBox1, Chr(13), ""), Chr(10))
With Sheets("Orders")
Set rng = .Range(.Range("A1"), .Range("A" & rows.Count).End(xlUp))
End With
Ray = Application.Transpose(rng.value)
With CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
Lpray = Array(Ray, TxRay)
For oLp = 0 To UBound(Lpray)
st = IIf(oLp = 1, 0, 1)
For R = st To UBound(Lpray(oLp))
If Not .Exists(Trim(Lpray(oLp)(R))) Then
.Add Trim(Lpray(oLp)(R)), ""
If oLp = 1 Then
Txt = Txt & Trim(Lpray(oLp)(R)) & Chr(10)
End If
End If
Next R
Next oLp
End With
With TextBox2
.MultiLine = True
.value = Txt
End With
End Sub

