Thread: Find specific text in cell

1. Find specific text in cell

Hey guys, This is my sheet:

Untitled.png
As you can see I need a macro that search a concatenation of "B1 - B2 - B3" in A4 and put in B4 the percentage relative to the string founded.

Can you give me some help? Thanks!

2. You don't need a macro to do this if you layout your input data in a table and can implement a formula like http://www.exceltactics.com/faster-m...p-concatenate/

3. GM,

If you decide you still need a macro, this code will do what you need

Code:
```Public Sub FindText()
'----------------------------
'DECLARE AND SET VARIABLES
Dim LastRow As Long, LastCol As Long, letters As String, s, t
LastRow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
LastCol = ActiveSheet.Cells(1, Application.Columns.Count).End(xlToLeft).Column
letters = ""
'----------------------------
'CYCLE THROUGH ROWS AND SPLIT EXPRESSIONS
For I = 4 To LastRow
s = Split(Cells(I, 1), "; ")
'----------------------------
'REMOVE "-" AND CONCATENATE LETTERS
For J = 0 To UBound(s)
t = Split(s(J), " - ")
For M = 0 To UBound(t) - 1
letters = letters & t(M)
Next M
'----------------------------
'FIND MATCHING LETTERS AND PLACE VALUES
For K = 2 To LastCol
If letters = Cells(1, K) & Cells(2, K) & Cells(3, K) Then
Cells(I, K) = t(UBound(t))
End If
Next K
letters = ""
Next J
Next I
End Sub```
HTH,
Maud