ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Comparing Values Needs Correction (https://www.excelbanter.com/excel-programming/280132-comparing-values-needs-correction.html)

-JB-[_14_]

Comparing Values Needs Correction
 
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
--------------------------------------------------------------------------------
Thanks,
Jim



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



All times are GMT +1. The time now is 01:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com