View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Searching a limited amount of rows in a vertical array

a bit quicker I would think
Sub findb()
x = Range("i1:i" & Range("b1")).Find("b").Row
MsgBox x
End Sub

or a formula
=VLOOKUP("b",INDIRECT("I1:I"&B1),1,0)
--
Don Guillett
SalesAid Software

"JLatham" wrote in message
...
He's asking is this a homework assignment for a class.

Also, is this solution to be a formula in a worksheet cell or is it to be
VB
code? Or will either do? What is being sought in the range A1:A100?
What
is supposed to be done/happen when you find what you're looking for?

If in VB, use the contents of cell B1 as the terminating value for a loop,
as (assumes sheet with data on it is Sheet1:

Worksheets("Sheet1").Select
Range("A1").select
For LoopCounter = 1 to Worksheets("Sheet1").Range("B1").Value
...move thru the cells and do testing inside the loop
Next

faster method would be to use LoopCounter as a row offset, which would
need
a setup like this:
Worksheets("Sheet1").Select
Range("A1").select
For LoopCounter = 0 to Worksheets("Sheet1").Range("B1").Value-1
...move thru the cells via .Offset and do testing inside the loop
Next

To be robust we'd want to add verification that the contents of B1 is
valid
(positive integer from 1 to 100) before beginning the loop.

"Joe Miller" wrote:


Hi Don Guillett,
I don't understand 'homework"?
Joe Miller


--
Joe Miller
------------------------------------------------------------------------
Joe Miller's Profile:
http://www.excelforum.com/member.php...o&userid=29900
View this thread:
http://www.excelforum.com/showthread...hreadid=573460