J
-JB-
Hi, and thanks in advance for any help....
Below, I have a section of a sub routine that counts the "words" of a
cell, and finds a word with the same amount of "words". If it is found,
it copys the cell to the next column. It works, but I need to modify
it. I need it to compare "number of words +2".
Example:
number of words to be compare with: "A B C" (3 words)
I want returned (as an exact match) "x A B C x" (5 words)
Another Example:
number of words to be compare with: "A B C D E F" (6 words)
I want returned (as an exact match) "z A B C D E F z" (8 words)
This is the code:
---------------------------------------------------------------------------------
With Sheets("Temp")
For Each Cell In .Range(.Cells(1, UBound(FWhat) + 1), _
.Cells(65536, UBound(FWhat) + 1).End(x1Up))
'If Len(Cell.Value) - Len(Replace(Cell.Value, " ", "")) =
If Len(Cell.Value) - Len(Replace(Cell.Value, " ", "")) = _
LastCol Then
.Cells(i + 1, LastCol + 1).Value = Cell.Value
ExactMatch = True
i = i + 1
End If
Next Cell
If Not ExactMatch Then
.Cells(i + 1, LastCol + 1).Value = "No Exact Match"
End If
End With
End Sub
Below, I have a section of a sub routine that counts the "words" of a
cell, and finds a word with the same amount of "words". If it is found,
it copys the cell to the next column. It works, but I need to modify
it. I need it to compare "number of words +2".
Example:
number of words to be compare with: "A B C" (3 words)
I want returned (as an exact match) "x A B C x" (5 words)
Another Example:
number of words to be compare with: "A B C D E F" (6 words)
I want returned (as an exact match) "z A B C D E F z" (8 words)
This is the code:
---------------------------------------------------------------------------------
With Sheets("Temp")
For Each Cell In .Range(.Cells(1, UBound(FWhat) + 1), _
.Cells(65536, UBound(FWhat) + 1).End(x1Up))
'If Len(Cell.Value) - Len(Replace(Cell.Value, " ", "")) =
If Len(Cell.Value) - Len(Replace(Cell.Value, " ", "")) = _
LastCol Then
.Cells(i + 1, LastCol + 1).Value = Cell.Value
ExactMatch = True
i = i + 1
End If
Next Cell
If Not ExactMatch Then
.Cells(i + 1, LastCol + 1).Value = "No Exact Match"
End If
End With
End Sub