Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default find cell with value greater than my number


I want to find/create a function that will sort through a column and
return the cell that has a value greater than 'my number'


in c. i want
i = 0;
while (columnC[i] < 'my number')
i++;

now i can use i as the index that i need.



Any ideas for excel,???
Thanks a lot!


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default find cell with value greater than my number

Public Function HigherThanMe(rng As Range, Target As Variant) As Range
Dim cell As Range
On Error GoTo ErrHandler
For Each cell In rng
On Error Resume Next
If cell.Value Target Then
Set HigherThanMe = cell
Exit For
End If
On Error GoTo 0
Next
End Function



This returns a reference to a range

If used in a cell

=HigerthanMe(A:A,21)

it would produce the value of the cell.

If you want the address declare the function as String

and

HigherThanMe = cell.Address(0,0,External:=True)

or to get the offset in the column (the index value you speak of)

Public Function HigherThanMe(rng As Range, Target As Variant) As Long
Dim cell As Range, Dim i a long
On Error GoTo ErrHandler
i = 0
For Each cell In rng
On Error Resume Next
i = i + 1
If cell.Value Target Then
HigherThanMe = i
Exit For
End If
On Error GoTo 0
Next
End Function


You could add checks to insure rng is a single, entire column.

--
Regards,
Tom Ogilvy


heiny06 wrote in message
...[i]

I want to find/create a function that will sort through a column and
return the cell that has a value greater than 'my number'


in c. i want
i = 0;
while (columnC < 'my number')
i++;

now i can use i as the index that i need.



Any ideas for excel,???
Thanks a lot!


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to

creating financial statements


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
SMALL function to find X smallest number greater than Y kittronald Excel Worksheet Functions 6 June 15th 11 12:35 AM
How can I make a cell red if number is not greater than needed? daisyp66 Excel Worksheet Functions 4 December 2nd 09 07:33 PM
Visual Script to find smallest number greater than 0 Jeremy Excel Discussion (Misc queries) 3 October 30th 09 08:32 PM
countif formula to find the occurances of a number that is greater than one number but less than another steveo Excel Discussion (Misc queries) 3 July 8th 06 02:04 AM
How can I get Excel to find the first number in a list greater tha krowlan Excel Worksheet Functions 3 October 27th 05 06:15 PM


All times are GMT +1. The time now is 09:03 AM.

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"