Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I select the first occurance of a number in a column

How do I select the first occurance of a certain number in a column and then,
as in the "Lookup" function, return a same numbered cell (different column).
I have "0's" and "1's" in my column (intermixed) and I am looking for the
first occurance of a "1". I then want to look up another value in the same
row (different column). "Lookup" function doesn't work if you have multiple
values not sorted. I'm using Excel 2003.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default How do I select the first occurance of a number in a column

=MATCH(1,C:C,FALSE)
This returns the first occurance in column C of the number 1...in my case th
eresult was 5, and row was also row 5 since my data started at row 1
If the match function is in B1, then in say B2 put

=OFFSET(G1,B1-1,0)

this uses the result of the match to get an item from column G that matches
the row indicated....the '-1' is the adjustemnt for the offset. For example
if we need row 5, then G1 offset 5 points at G6, so we reduce the offset by
one G1 offset(5-1) now points to G5




"Corner920" wrote:

How do I select the first occurance of a certain number in a column and then,
as in the "Lookup" function, return a same numbered cell (different column).
I have "0's" and "1's" in my column (intermixed) and I am looking for the
first occurance of a "1". I then want to look up another value in the same
row (different column). "Lookup" function doesn't work if you have multiple
values not sorted. I'm using Excel 2003.

  #3   Report Post  
Posted to microsoft.public.excel.programming
KL KL is offline
external usenet poster
 
Posts: 201
Default How do I select the first occurance of a number in a column

Hi Corner920,

You don't have to select the searched cell in order to get the value. Try
something like this:

Sub Test()
With Columns("A:A")
MsgBox .Find( _
What:=1, _
After:=.Cells(1), _
LookIn:=xlValues, _
LookAt:= _
xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext) _
.Offset(0, 1).Value
End With
End Sub

or a slightly shorter version:

Sub Macro5()
With Columns("A:A")
MsgBox .Find(1, .Cells(1), xlValues, _
xlWhole, xlByRows, xlNext).Offset(0, 1).Value
End With
End Sub

Regards,
KL

"Corner920" wrote in message
...
How do I select the first occurance of a certain number in a column and
then,
as in the "Lookup" function, return a same numbered cell (different
column).
I have "0's" and "1's" in my column (intermixed) and I am looking for the
first occurance of a "1". I then want to look up another value in the
same
row (different column). "Lookup" function doesn't work if you have
multiple
values not sorted. I'm using Excel 2003.



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
Select number from leftmost column that has one widman Excel Discussion (Misc queries) 4 April 29th 10 02:05 AM
Select range using row and column number addresses NDBC Excel Discussion (Misc queries) 4 July 22nd 09 06:51 AM
How to define and select the last (bottom) number in a column? BrendaN_at_Welke_Customs Excel Worksheet Functions 24 November 5th 07 05:06 AM
Count occurance of largest duplicate number in a single column ran catpro New Users to Excel 5 January 21st 07 05:10 PM
Locating Cell Number of first occurance of data in Column genzu Excel Programming 6 June 16th 04 03:44 AM


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