ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loop and find less than... (https://www.excelbanter.com/excel-programming/338715-loop-find-less-than.html)

John

Loop and find less than...
 
Is there a way to find cells in a loop that are less than a certian value?
something like that idea, but I know this doesn't work...
Set rngFound = rngToSearch.Find <= (Range("a56").Value)

Tom Ogilvy

Loop and find less than...
 
Dim rng as Range, cell as Range
for each cell in Range("B1:B100")
if cell.Value < Range("A56").Value then
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
rng.Select
End if

--
Regards,
Tom Ogilvy

"John" wrote in message
...
Is there a way to find cells in a loop that are less than a certian value?
something like that idea, but I know this doesn't work...
Set rngFound = rngToSearch.Find <= (Range("a56").Value)




John

Loop and find less than...
 
Thank you sir!

"Tom Ogilvy" wrote:

Dim rng as Range, cell as Range
for each cell in Range("B1:B100")
if cell.Value < Range("A56").Value then
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
rng.Select
End if

--
Regards,
Tom Ogilvy

"John" wrote in message
...
Is there a way to find cells in a loop that are less than a certian value?
something like that idea, but I know this doesn't work...
Set rngFound = rngToSearch.Find <= (Range("a56").Value)






All times are GMT +1. The time now is 07:27 PM.

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