Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
J@Y J@Y is offline
external usenet poster
 
Posts: 127
Default Search from the bottom of a Range up

Is there an efficient way to searching from the bottom of a range up?

I have this:

for counter = 1 to 200
if cells(200-counter, 1) = "blah") then...
endif
next counter
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Search from the bottom of a Range up

for counter = 200 to 1 Step -1
if cells(200-counter, 1) = "blah") then...
end if
next counter


"J@Y" wrote in message
...
Is there an efficient way to searching from the bottom of a range up?

I have this:

for counter = 1 to 200
if cells(200-counter, 1) = "blah") then...
endif
next counter



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Search from the bottom of a Range up

for counter = 200 to 1 step -1
if cells(counter, 1) = "blah") then...
endif
next counter

or more convoluted:

for counter = 1 to 200
if cells(201-counter, 1) = "blah") then...
endif
next counter



J@Y wrote:

Is there an efficient way to searching from the bottom of a range up?

I have this:

for counter = 1 to 200
if cells(200-counter, 1) = "blah") then...
endif
next counter


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Search from the bottom of a Range up

Hi

if it is an Excel range, cannot you use the built-in functionality?
Something like:
Selection.Find(What:="blah", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious,
MatchCase:= _
False).Activate
i.e. use the SearchDirection parameter

hth (and is correct !)

Tim


"Trevor Shuttleworth" wrote in message
...
for counter = 200 to 1 Step -1
if cells(200-counter, 1) = "blah") then...
end if
next counter


"J@Y" wrote in message
...
Is there an efficient way to searching from the bottom of a range up?

I have this:

for counter = 1 to 200
if cells(200-counter, 1) = "blah") then...
endif
next counter





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Search from the bottom of a Range up

Dave

me too! but it would have taken me too long to puzzle out the VB code!!

bw

Tim

"Dave Peterson" wrote in message
...
If I wanted to find the last value in a range (say a column), I'd start in

the
first (top) cell and look up (xlprevious) from there. I wouldn't start

with the
activecell.

dim FoundCell as range
with worksheets("sheet9999")
with .range("a1:A9999")
set foundcell = .Find(What:="blah", _
After:=.cells(1), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False)
end with
end with

if foundcell is nothing then
msgbox "not found"
else
msgbox foundcell.value & " was found " & foundcell.address
end if

====
And if I wanted to find the first entry in that column, I'd start in the

last
cell and look down (xlnext).

dim FoundCell as range
with worksheets("sheet9999")
with .range("a1:A9999")
set foundcell = .Find(What:="blah", _
After:=.cells(.cells.count), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
end with
end with

=======
And if I had to search for more entries, I'd look in VBA's help for

..findnext().


Tim Childs wrote:

Hi

if it is an Excel range, cannot you use the built-in functionality?
Something like:
Selection.Find(What:="blah", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious,
MatchCase:= _
False).Activate
i.e. use the SearchDirection parameter

hth (and is correct !)

Tim

"Trevor Shuttleworth" wrote in message
...
for counter = 200 to 1 Step -1
if cells(200-counter, 1) = "blah") then...
end if
next counter


"J@Y" wrote in message
...
Is there an efficient way to searching from the bottom of a range

up?

I have this:

for counter = 1 to 200
if cells(200-counter, 1) = "blah") then...
endif
next counter



--

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
search an array in reverse (bottom to top) order Trainer_00 Excel Discussion (Misc queries) 5 December 20th 07 10:35 PM
Loop a range from bottom up Who I Am Excel Programming 3 July 21st 06 07:51 PM
Adding in row at bottom of range Graham Haughs Excel Programming 4 March 27th 06 08:03 PM
starting from bottom of range instead of top davegb Excel Programming 4 March 8th 06 07:46 PM
How to: Add blank row at bottom of range Brad Clarke Excel Programming 2 November 30th 03 10:20 PM


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