Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Loop through single column of named range

Hi,

I have a named range that covers A1:d4 - How do I loop through each cell in
Column C of the named range.

I know how to do it for a 'non-named' range but not for a named range

TIA

Andi


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Loop through single column of named range

I would be inclined to use the intersect method something like this

dim rngToSearch as Range
dim rng as range

on error resume next
set rngtosearch = intersect(columns("C"), range("MyRange"))
on error goto 0

if rngtosearch is nothing then
msgbox "The range name changed and we have a problem."
else
for each rng in rngtosearch
msgbox rng.address
next rng
end if
--
HTH...

Jim Thomlinson


"Andibevan" wrote:

Hi,

I have a named range that covers A1:d4 - How do I loop through each cell in
Column C of the named range.

I know how to do it for a 'non-named' range but not for a named range

TIA

Andi



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Loop through single column of named range

Dim myCell as range
dim myRng as range
set myrng = worksheets("somesheet").range("somename")
for each mycell in myrng.columns(3).cells
msgbox mycell.address '???
next mycell

There better be at least 3 columns in that range!


Andibevan wrote:

Hi,

I have a named range that covers A1:d4 - How do I loop through each cell in
Column C of the named range.

I know how to do it for a 'non-named' range but not for a named range

TIA

Andi


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Loop through single column of named range

Thanks Dave - I was messing around with that idea but had missed the .cell
off the end of the statement

Ta muchly


"Dave Peterson" wrote in message
...
Dim myCell as range
dim myRng as range
set myrng = worksheets("somesheet").range("somename")
for each mycell in myrng.columns(3).cells
msgbox mycell.address '???
next mycell

There better be at least 3 columns in that range!


Andibevan wrote:

Hi,

I have a named range that covers A1:d4 - How do I loop through each cell

in
Column C of the named range.

I know how to do it for a 'non-named' range but not for a named range

TIA

Andi


--

Dave Peterson



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Loop through single column of named range

It's not always required, but it never hurts (and it can be painful if you
needed it and didn't use it!).

Andibevan wrote:

Thanks Dave - I was messing around with that idea but had missed the .cell
off the end of the statement

Ta muchly

"Dave Peterson" wrote in message
...
Dim myCell as range
dim myRng as range
set myrng = worksheets("somesheet").range("somename")
for each mycell in myrng.columns(3).cells
msgbox mycell.address '???
next mycell

There better be at least 3 columns in that range!


Andibevan wrote:

Hi,

I have a named range that covers A1:d4 - How do I loop through each cell

in
Column C of the named range.

I know how to do it for a 'non-named' range but not for a named range

TIA

Andi


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query Named Range Return Single Column Value JeffP-> Excel Worksheet Functions 5 November 29th 07 10:30 PM
Find first blank cell in single column named range tig Excel Programming 9 February 9th 06 05:39 PM
Redefining a Named Range In A Loop Frank[_8_] Excel Programming 3 October 24th 05 03:35 PM
Loop thru named range of second sheet Bill Sturdevant[_2_] Excel Programming 3 July 29th 05 07:15 PM
Identifying single column within named range ESAEO Excel Discussion (Misc queries) 2 March 24th 05 09:30 PM


All times are GMT +1. The time now is 08:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"