Split function to search for value in worksheet

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

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
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
You need to specify which part of the array you want to use for the string like
VBA Code:
myvalue3 = JArray(0) & " Psychologically"
 
Upvote 0
You need to specify which part of the array you want to use for the string like
VBA Code:
myvalue3 = JArray(0) & " Psychologically"
Aaaaaaaaaahhhhhhhhhh

So much relief!!!
Thanks so much, its so great to see it all working smoothly thanks to you Fluff and that wee zero!!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,924
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top