ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Named Range (https://www.excelbanter.com/excel-programming/274729-re-named-range.html)

Tom Ogilvy

Named Range
 
Assume the name of the Range is MyRange

Dim cell as Range
for each cell in Range("MyRange")
if isnumeric(cell) then ' necessary in xl97
if cell.value = 10 then cell.value = 20
End if
Next cell

or

Dim cell as Range
for each cell in Range("MyRange").SpecialCells(xlConstants,xlNumber s)
if cell.value = 10 then cell.value = 20
Next cell

--
Regards,
Tom Ogilvy


"Mark M." wrote in message
...
I have a named range that is 10 rows by 10 columns.

If possible, I'd like to use the "For Each" construct to
go thru the range.

Could somebody give me some sample code?

I would think the code would look some thing like this:

Dim clCell as Cell
For Each clCell in NamedRange
if clCell.Value = 10 then clCell.value = 20
Next clCell

Thank you for your help,

MarkM





MarkM[_3_]

Thanks for the help
 
Dim'ing the Cell as a range is obvious now that I see it.

Thanks for the clear thinking.

Mark


-----Original Message-----
Assume the name of the Range is MyRange

Dim cell as Range
for each cell in Range("MyRange")
if isnumeric(cell) then ' necessary in xl97
if cell.value = 10 then cell.value = 20
End if
Next cell

or

Dim cell as Range
for each cell in Range("MyRange").SpecialCells

(xlConstants,xlNumbers)
if cell.value = 10 then cell.value = 20
Next cell

--
Regards,
Tom Ogilvy


"Mark M." wrote in message
...
I have a named range that is 10 rows by 10 columns.

If possible, I'd like to use the "For Each" construct

to
go thru the range.

Could somebody give me some sample code?

I would think the code would look some thing like this:

Dim clCell as Cell
For Each clCell in NamedRange
if clCell.Value = 10 then clCell.value = 20
Next clCell

Thank you for your help,

MarkM




.



All times are GMT +1. The time now is 09:54 AM.

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