Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8
Default Invalid LOOKUP Function Results

The notes for LOOKUP function indicate the values in a row must be sorted or
invalid results will occur. Is there a way to get around this? How can I
use the LOOKUP function or any other lookup function to correctly return
results on an unsorted row of data? Below is an example of what I need to
accomplish:

C1 - C4 are column headers (text values)

A B C D
1 C1 C2 C3 C4
2 5 3 2 4

=lookup(5,A2:D2,A1:D1)

Actual / Invalid Result: C4
Correct / Needed Result: C1

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Invalid LOOKUP Function Results

Try

=INDEX($A$1:$D$1,MATCH(A8,$A$2:$D$2,0))

Where A8 is the value you are matching

Mike

"lmavroff" wrote:

The notes for LOOKUP function indicate the values in a row must be sorted or
invalid results will occur. Is there a way to get around this? How can I
use the LOOKUP function or any other lookup function to correctly return
results on an unsorted row of data? Below is an example of what I need to
accomplish:

C1 - C4 are column headers (text values)

A B C D
1 C1 C2 C3 C4
2 5 3 2 4

=lookup(5,A2:D2,A1:D1)

Actual / Invalid Result: C4
Correct / Needed Result: C1

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8
Default Invalid LOOKUP Function Results

Thanks, Mike.

"Mike H" wrote:

Try

=INDEX($A$1:$D$1,MATCH(A8,$A$2:$D$2,0))

Where A8 is the value you are matching

Mike

"lmavroff" wrote:

The notes for LOOKUP function indicate the values in a row must be sorted or
invalid results will occur. Is there a way to get around this? How can I
use the LOOKUP function or any other lookup function to correctly return
results on an unsorted row of data? Below is an example of what I need to
accomplish:

C1 - C4 are column headers (text values)

A B C D
1 C1 C2 C3 C4
2 5 3 2 4

=lookup(5,A2:D2,A1:D1)

Actual / Invalid Result: C4
Correct / Needed Result: C1

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8
Default Invalid LOOKUP Function Results

Is there a way to exclude values in hidden columns?

"Mike H" wrote:

Try

=INDEX($A$1:$D$1,MATCH(A8,$A$2:$D$2,0))

Where A8 is the value you are matching

Mike

"lmavroff" wrote:

The notes for LOOKUP function indicate the values in a row must be sorted or
invalid results will occur. Is there a way to get around this? How can I
use the LOOKUP function or any other lookup function to correctly return
results on an unsorted row of data? Below is an example of what I need to
accomplish:

C1 - C4 are column headers (text values)

A B C D
1 C1 C2 C3 C4
2 5 3 2 4

=lookup(5,A2:D2,A1:D1)

Actual / Invalid Result: C4
Correct / Needed Result: C1

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Invalid LOOKUP Function Results

I suspect you need vb for that. Try this UDF which must go in a general module

Call with
=visiblelookup(A2:D2,A8,A1:D1)

A2:D2 is the range to look in
A8 is what to look for
A1:D1 is the range to return
Both range must be the same length. Not extensively test but I think it
works with any 2 ranges of the same size rows or columns or mixed rows and
columns.

Function visiblelookup(rng As Range, lookvalue As String, returnrng As
Range) As String
If rng.Cells.Count < returnrng.Cells.Count Then
visiblelookup = "Invalid Range"
Exit Function
End If
For Each C In rng
pos = pos + 1
If C.ColumnWidth < 0 And CStr(C.Value) = lookvalue Then
visiblelookup = returnrng.Cells(pos)
Exit For
End If
Next
End Function


Mike

"lmavroff" wrote:

Is there a way to exclude values in hidden columns?

"Mike H" wrote:

Try

=INDEX($A$1:$D$1,MATCH(A8,$A$2:$D$2,0))

Where A8 is the value you are matching

Mike

"lmavroff" wrote:

The notes for LOOKUP function indicate the values in a row must be sorted or
invalid results will occur. Is there a way to get around this? How can I
use the LOOKUP function or any other lookup function to correctly return
results on an unsorted row of data? Below is an example of what I need to
accomplish:

C1 - C4 are column headers (text values)

A B C D
1 C1 C2 C3 C4
2 5 3 2 4

=lookup(5,A2:D2,A1:D1)

Actual / Invalid Result: C4
Correct / Needed Result: C1



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Invalid LOOKUP Function Results

it should now work for hidden columns or rows

Function visiblelookup(rng As Range, lookvalue As String, returnrng As
Range) As String
If rng.Cells.Count < returnrng.Cells.Count Then
visiblelookup = "Invalid Range"
Exit Function
End If
For Each C In rng
pos = pos + 1
If C.ColumnWidth = 0 Or C.RowHeight = 0 Then GoTo itshidden
If CStr(C.Value) = lookvalue Then
visiblelookup = returnrng.Cells(pos)
Exit For
End If
itshidden:
Next
End Function

Mike

"Mike H" wrote:

I suspect you need vb for that. Try this UDF which must go in a general module

Call with
=visiblelookup(A2:D2,A8,A1:D1)

A2:D2 is the range to look in
A8 is what to look for
A1:D1 is the range to return
Both range must be the same length. Not extensively test but I think it
works with any 2 ranges of the same size rows or columns or mixed rows and
columns.

Function visiblelookup(rng As Range, lookvalue As String, returnrng As
Range) As String
If rng.Cells.Count < returnrng.Cells.Count Then
visiblelookup = "Invalid Range"
Exit Function
End If
For Each C In rng
pos = pos + 1
If C.ColumnWidth < 0 And CStr(C.Value) = lookvalue Then
visiblelookup = returnrng.Cells(pos)
Exit For
End If
Next
End Function


Mike

"lmavroff" wrote:

Is there a way to exclude values in hidden columns?

"Mike H" wrote:

Try

=INDEX($A$1:$D$1,MATCH(A8,$A$2:$D$2,0))

Where A8 is the value you are matching

Mike

"lmavroff" wrote:

The notes for LOOKUP function indicate the values in a row must be sorted or
invalid results will occur. Is there a way to get around this? How can I
use the LOOKUP function or any other lookup function to correctly return
results on an unsorted row of data? Below is an example of what I need to
accomplish:

C1 - C4 are column headers (text values)

A B C D
1 C1 C2 C3 C4
2 5 3 2 4

=lookup(5,A2:D2,A1:D1)

Actual / Invalid Result: C4
Correct / Needed Result: C1

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Invalid LOOKUP Function Results

Try instead: =INDEX(A1:D1,MATCH(5,A2:D2,0))
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:17,400 Files:358 Subscribers:55
xdemechanik
---
"lmavroff" wrote:
The notes for LOOKUP function indicate the values in a row must be sorted or
invalid results will occur. Is there a way to get around this? How can I
use the LOOKUP function or any other lookup function to correctly return
results on an unsorted row of data? Below is an example of what I need to
accomplish:

C1 - C4 are column headers (text values)

A B C D
1 C1 C2 C3 C4
2 5 3 2 4

=lookup(5,A2:D2,A1:D1)

Actual / Invalid Result: C4
Correct / Needed Result: C1

  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8
Default Invalid LOOKUP Function Results

Thanks, Max.

"Max" wrote:

Try instead: =INDEX(A1:D1,MATCH(5,A2:D2,0))
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:17,400 Files:358 Subscribers:55
xdemechanik
---
"lmavroff" wrote:
The notes for LOOKUP function indicate the values in a row must be sorted or
invalid results will occur. Is there a way to get around this? How can I
use the LOOKUP function or any other lookup function to correctly return
results on an unsorted row of data? Below is an example of what I need to
accomplish:

C1 - C4 are column headers (text values)

A B C D
1 C1 C2 C3 C4
2 5 3 2 4

=lookup(5,A2:D2,A1:D1)

Actual / Invalid Result: C4
Correct / Needed Result: C1

  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8
Default Invalid LOOKUP Function Results

Is there a way to exclude values in hidden columns?

"Max" wrote:

Try instead: =INDEX(A1:D1,MATCH(5,A2:D2,0))
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:17,400 Files:358 Subscribers:55
xdemechanik
---
"lmavroff" wrote:
The notes for LOOKUP function indicate the values in a row must be sorted or
invalid results will occur. Is there a way to get around this? How can I
use the LOOKUP function or any other lookup function to correctly return
results on an unsorted row of data? Below is an example of what I need to
accomplish:

C1 - C4 are column headers (text values)

A B C D
1 C1 C2 C3 C4
2 5 3 2 4

=lookup(5,A2:D2,A1:D1)

Actual / Invalid Result: C4
Correct / Needed Result: C1

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
Getting correct results for lookup? tgcali Excel Discussion (Misc queries) 4 July 15th 08 02:32 AM
Lookup and List Results DSCAVOTTO Excel Worksheet Functions 5 April 21st 06 08:59 PM
summing lookup results Martyn Excel Discussion (Misc queries) 4 March 2nd 06 09:25 AM
lookup and show all results JAHanlon Excel Worksheet Functions 3 January 7th 06 11:46 PM
How can I do a lookup and get multiple row results? Rashmi Excel Worksheet Functions 10 August 19th 05 02:04 AM


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