ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If Cell.Value = [???] and <=[?????] Then (https://www.excelbanter.com/excel-programming/277411-re-if-cell-value-%3D-%5B-%5D-%3D%5B-%5D-then.html)

Tom Ogilvy

If Cell.Value = [???] and <=[?????] Then
 
Dim cell as Range
Dim rng as Range
for each cell in Range("A1:B5")
if len(cell.Value) = 3 and len(cell.Value)<= 5 then
msgbox cell.Address & " has a length of " & len(cell.Value)
if rng is nothing then
set rng = cell
else
set rng = Union(rng,cell)
End if
end if
Next
if not rng is nothing then
msgbox "found cells: " & rng.Address(0,0)
End if

--
Regards,
Tom Ogilvy


Kobayashi wrote in message
...
I have tried to search the forum but haven't been able to find anything
so please forgive me if this has been covered previously?

How can I perform an If function, in a For... loop, whereby I wish to
find all cells with a value ( and perhaps using value is wha'ts wrong?)
between three and five characters (?) in length?

Thanks once again,

Adrian



------------------------------------------------
~~ 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 07:12 PM.

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