LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default A question relating to "for each cell_in_loop in range"

I realize this is a somewhat more advance question while at the
same time somewhat simple. At the same time my problem has to
do with a rather bizarre.. well, let me describe the situation.

Given
ExitLine = 2000
For each cell_in_loop In Range("H2:H2000")
If (cell_in_loop.Offset(0, -7).Value = "EOList") Then
' ExitLine = ' ?? <------- This is where the problem arises
Exit For
End If
: Lengthy list of instructions
Next
MsgBox "Exited after line " & ExitLine

As you can see, this is, quite simply put, a straight forward,
"for...next" loop with no real "gotcha's" beyond a more-or-less
straight forward "get out early" clause which is also quite
straight forward.

I can know, with a fair degree of certainty that if the "loop
runs to the end" I have 2000 (or more) lines of data. Here's
where I've run into the problem. I haven't been able to find
a way to find out where I leave the loop, when I leave the
loop, early. I know there must be a way and I'm sure it's
quite simple, but for the life of me it's escaping me.

I've tried toying around with the internals of the "offset"
using "application.row()" but the compiler complains and
when I can get it to a run-able state it blows up as soon
as it hits that line.

I've tried counters but that got too convoluted to be
cleanly implemented (since the columns might have to
be sorted from time-to-time) and "EOList" may move to
a different place. (And the code was *butt crack ugly"
and too hard to hard to read as well. The understanding
or comprehension required a brain-damaged chimp with a
Ph.D in some obscure language no one has spoken for ten
million years. I'd like to leave code that the next guy
could "fix," if he had too, without boiling me in VR oil
each time he had to do a "fix.")

I tried some C++ routines but it was too easy to get lost
between the "external calls" to be certain I was really
certain that what I was getting was a correct value. (I
mean it "looked right" but it "looked wrong" too.)

So, I'll entertain all suggestions on how I can find out that
when I find "EOList" that the last line of usable data was:
"Row() - 1?"

Looking forward to good ideas.


David

(Newsgroups have *never* failed me in the past and I the idea
of them doing so now is "inconceivable." I can't even picture
the idea of them doing so now. - With slight credit to "The
Brute" in "The Princess Bride")




 
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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
"Disk is Full" add-on question to "Can't reset last cell" post tod [email protected] Excel Discussion (Misc queries) 0 January 22nd 07 02:32 AM
Using "Cells" to write "Range("A:A,H:H").Select" Trip Ives[_2_] Excel Programming 3 June 5th 04 03:13 PM
Question about sorting and "key" range values TBA[_2_] Excel Programming 3 September 25th 03 02:01 PM


All times are GMT +1. The time now is 01:19 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"