ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Comparing a range with text (https://www.excelbanter.com/excel-programming/304183-comparing-range-text.html)

Frood

Comparing a range with text
 
Hello all,

I hope someboy can help with this, I have defined a name (Text_range)
for a range of cells.
I would like to write a macro that compares all cells in the range
with a string.

The reason I want to refer to the defined name for the cells is
because the range is not continuous
(=Results!$A$16:$A$84,Results!$A$86:$A$241...etc).

Any help would be much appreciated.

Ray

Frank Kabel

Comparing a range with text
 
Hi
try somthing like
sub foo()
dim rng as range
dim cell as range
set rng = Range("Text_range")
for each cell in rng
if cell.value="your_test_value" then
msgbox "Found value in cell: " cell.address
end if
next
end sub

--
Regards
Frank Kabel
Frankfurt, Germany


Frood wrote:
Hello all,

I hope someboy can help with this, I have defined a name (Text_range)
for a range of cells.
I would like to write a macro that compares all cells in the range
with a string.

The reason I want to refer to the defined name for the cells is
because the range is not continuous
(=Results!$A$16:$A$84,Results!$A$86:$A$241...etc).

Any help would be much appreciated.

Ray




All times are GMT +1. The time now is 01:15 PM.

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