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

I have a Loop that I want to go until it is out of my named range
something like so


Lets say I have a named range called "HiField"
"""""""""""""""""""""""""""""""""""""""""""""""""" """""""
Dim ntotal as string

ntotal = 0

Do
Range("CP1").Offset(ntotal, 0) = "HI"
ntotal = ntotal + 1
Loop Until out of HiField <------This is were I need Help

How would I go about telling it to loop until out of named range

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Loop Until out of named range


You can use intersect
set ColCPRange = Range("CP:CP")

set Newrange = Application.Intersect(ColCPRange, HiField)
for each cell in NewRange

next cell

" wrote:

I have a Loop that I want to go until it is out of my named range
something like so


Lets say I have a named range called "HiField"
"""""""""""""""""""""""""""""""""""""""""""""""""" """""""
Dim ntotal as string

ntotal = 0

Do
Range("CP1").Offset(ntotal, 0) = "HI"
ntotal = ntotal + 1
Loop Until out of HiField <------This is were I need Help

How would I go about telling it to loop until out of named range


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 272
Default Loop Until out of named range

Loop Until Intersect(Range("CP1").Offest(ntotal,0),Range("HiF ield")) Is Nothing

--
Charles Chickering

"A good example is twice the value of good advice."


" wrote:

I have a Loop that I want to go until it is out of my named range
something like so


Lets say I have a named range called "HiField"
"""""""""""""""""""""""""""""""""""""""""""""""""" """""""
Dim ntotal as string

ntotal = 0

Do
Range("CP1").Offset(ntotal, 0) = "HI"
ntotal = ntotal + 1
Loop Until out of HiField <------This is were I need Help

How would I go about telling it to loop until out of named range


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Loop Until out of named range

This should work:

ntotal = 0
For Each cell in ActiveSheet.Range("HiField")
Range("CP1").Offset(ntotal, 0) = "Hi"
ntotal = ntotal + 1
Next

" wrote:

I have a Loop that I want to go until it is out of my named range
something like so


Lets say I have a named range called "HiField"
"""""""""""""""""""""""""""""""""""""""""""""""""" """""""
Dim ntotal as string

ntotal = 0

Do
Range("CP1").Offset(ntotal, 0) = "HI"
ntotal = ntotal + 1
Loop Until out of HiField <------This is were I need Help

How would I go about telling it to loop until out of named range


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Loop Until out of named range

P.S. Don't Dim ntotal as string if you are going to use it as an integer. It
will cause a type mismatch error.

" wrote:

I have a Loop that I want to go until it is out of my named range
something like so


Lets say I have a named range called "HiField"
"""""""""""""""""""""""""""""""""""""""""""""""""" """""""
Dim ntotal as string

ntotal = 0

Do
Range("CP1").Offset(ntotal, 0) = "HI"
ntotal = ntotal + 1
Loop Until out of HiField <------This is were I need Help

How would I go about telling it to loop until out of named range




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 468
Default Loop Until out of named range

Not sure is I'm getting the full meaning of your q, but

Sub tester()
For Each c In Range("Test")
MsgBox "Your Value is " & c.Value
Next c
End Sub

This worked for me (Test is a named range
C4:C7 - with values 123,456,789,001



" wrote:

I have a Loop that I want to go until it is out of my named range
something like so


Lets say I have a named range called "HiField"
"""""""""""""""""""""""""""""""""""""""""""""""""" """""""
Dim ntotal as string

ntotal = 0

Do
Range("CP1").Offset(ntotal, 0) = "HI"
ntotal = ntotal + 1
Loop Until out of HiField <------This is were I need Help

How would I go about telling it to loop until out of named range


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
Loop through single column of named range Andibevan Excel Programming 4 September 5th 06 08:02 PM
Redefining a Named Range In A Loop Frank[_8_] Excel Programming 3 October 24th 05 03:35 PM
If any cell in named range = 8 then shade named range JJ[_8_] Excel Programming 3 August 26th 05 11:09 PM
Loop thru named range of second sheet Bill Sturdevant[_2_] Excel Programming 3 July 29th 05 07:15 PM
plz help: creating named range in VBA, loop goes haywire KR Excel Programming 2 April 14th 05 07:25 PM


All times are GMT +1. The time now is 04:41 PM.

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

About Us

"It's about Microsoft Excel"