Mikeymike_W
Board Regular
- Joined
- Feb 25, 2016
- Messages
- 171
Hi and thanks for any help you can give,
I am trying to use the code below to extract partial text (Everything before the hyphon) from a textbox (TBRandA).
I am then wanting to use this value (JArray) to search and return a value from my worsheet.
When i use JArray as part of "Myvalue3" it says there is a type mismatch highlighting the "&".
i've used this code with other functions so know it works but have never used it with the split function/Array value before so not sure how to adjust the code for it.
I had used a work around where i got the split function to populate a hidden textbox with the resultant value then use that textbox as part of myvalue3 but this was messy and seems to cause my workbook to glitch.
Thanks for your help,
Mike
I am trying to use the code below to extract partial text (Everything before the hyphon) from a textbox (TBRandA).
I am then wanting to use this value (JArray) to search and return a value from my worsheet.
When i use JArray as part of "Myvalue3" it says there is a type mismatch highlighting the "&".
i've used this code with other functions so know it works but have never used it with the split function/Array value before so not sure how to adjust the code for it.
I had used a work around where i got the split function to populate a hidden textbox with the resultant value then use that textbox as part of myvalue3 but this was messy and seems to cause my workbook to glitch.
Thanks for your help,
Mike
VBA Code:
Dim R As Worksheet
Dim myvalue3 As String
Dim t As Range
Dim JString As String
Dim JArray() As String
JString = TBRandA.Value
JArray = Split(JString, " -")
Set R = Worksheets("Interpretations")
myvalue3 = JArray & " Psychologically"
Set t = R.Range("A:MM").Find(myvalue3, LookIn:=xlValues, lookat:=xlWhole)
If Not t Is Nothing Then
TBPsychology.Value = t.Offset(0, 1).Value
End If