Find Value from a Cell in String and return the word

ivanmcgurk21

New Member
Joined
Oct 14, 2017
Messages
8
Hello,

I have done some searching but unfortunately I cannot find a solution.

I need to be able to find and return a word from a string, based on the value of a given cell so I can include the returned word as part of another code. Please see below for a basic example of what I am trying to do.

abc
1AAEASD EDR AAEEXTRACT AAE FROM STRING & RETURN HERE<extract aae="" from="" b1="" &="" return="" here=""></extract>

<tbody>
</tbody>


<return aae="" from="" string="" here=""><return aae="" here="">The string I have included in 'b' in reality is in another sheet, so I need to be able to identify if the value is in the string so I can copy that row.

Thanks in advance.</return></return>
 
Last edited:

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Hi,

Are you looking for something like below:

ABC
1AAEASD EDR AAEAAE
2AAEASD EDR ASEERROR TEXT

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
C1=IFERROR(MID(B1,SEARCH(A1,B1),LEN(A1)),"ERROR TEXT")
C2=IFERROR(MID(B2,SEARCH(A2,B2),LEN(A2)),"ERROR TEXT")

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
Hello,

Thanks for the quick reply. Sorry, I should have said that I'm trying to work this out in VBA.

I basically have one sheet with a list of single codes and another where cells may contain multiple codes. I need to be able to identify if a cell with multiple codes includes the code shown in a given cell. If the code is found within that string then copy that row into another sheet.
 
Upvote 0
I have managed to get a code that does copy the rows in, but it copies all rows and not just the ones that meet the criteria. I think there is an issue in the for loop, can anyone help me out here?

Private Sub CommandButton1_Click()


Dim xRg As Range
Dim xCell As Range
Dim I As Long
Dim J As Long
Dim K As Long
I = Worksheets("MASTER LIST").UsedRange.Rows.Count
J = Worksheets("VALIDATED LIST").UsedRange.Rows.Count
If J = 1 Then
If Application.WorksheetFunction.CountA(Worksheets("VALIDATED LIST").UsedRange) = 0 Then J = 0
End If
Set xRg = Worksheets("MASTER LIST").Range("E1:E" & I)
On Error Resume Next
Application.ScreenUpdating = True

For K = 1 To xRg.Count
If CStr(xRg(K).Value) = InStr(Worksheets("MASTER LIST").Range("E1:E" & I).Value, Worksheets("TRANSPOSED DATA NO SPACES").Range("B1:B" & J)) > 1 Then
xRg(K).EntireRow.Copy Destination:=Worksheets("VALIDATED LIST").Range("A" & J + 1)
J = J + 1
End If
Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,028
Messages
6,122,753
Members
449,094
Latest member
dsharae57

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