Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
 
Posts: n/a
Default How to find a row since I found a value in a column? see example

Hi,
Here is my example:

The situation:
I have a table where we add numbers at the bottom. (bottom is most
recent) I want to find the most recent number of row B (calling it
FindLastEntry2)(done by the function below)
--- I want to output the number x in column A corresponding to the
same row as the the FindLastEntry2 number.

Example:
A B
1 23
2 42
1
3 8
4 44
4

------------------------
Function FindLastEntry2(rng)
On Error Resume Next 'ignore errors if input is not a range
nRows = rng.Rows.Count 'count rows in input range
nCols = rng.Columns.Count 'count columns in input range
If nCols = 1 Then 'if one column, search rows
n = nRows
Do Until rng.Cells(n, 1).Value < 0 Or n = 1
'loop from last row up until non zero found or top of range
n = n - 1
Loop
FindLastEntry2 = rng.Cells(n, 1).Value 'return value found
ElseIf nRows = 1 Then 'if one row search columns
n = nCols
Do Until rng.Cells(1, n).Value < 0 Or n = 1
n = n - 1
Loop
FindLastEntry2 = rng.Cells(n, 1).Value
Else ' if not a single row or column, return message
FindLastEntry2 = "Please specify a single row or column"
End If
End Function
-----------------------------

Nick

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
 
Posts: n/a
Default How to find a row since I found a value in a column? see example

I forgot to mention that sometimes there is more than one time the same
value in column B

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
Find a string within a column Rookie_User Excel Discussion (Misc queries) 8 March 17th 06 02:12 PM
Macro to find text string in a column and paste data in another nicolascap Excel Discussion (Misc queries) 8 March 14th 06 03:13 PM
Lookup Table Dilemma Karen Excel Worksheet Functions 2 June 10th 05 08:22 PM
up to 7 functions? ALex Excel Worksheet Functions 10 April 12th 05 06:42 PM
I need to find the Average from Column A - but Reference Column B BAM718 Excel Worksheet Functions 2 March 15th 05 02:42 PM


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