Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
KP KP is offline
external usenet poster
 
Posts: 13
Default Extracting value froma table

I have a table with three variables. I need to extract data based on the
value of three variables. For example:

Column 1 Column2 Column3 Column4 and so on...
4 5
10 8 8-0.25 8-0.375
10 12 10-0.25 10-.0375
12 8 9-0.188 9-0.375
12 12 11-0.375 12-0.25

Based on the above data, I would like to extract data when column1 is 10,
column2 is 12 and value in the first row is 5. The answer should be
10-0.375. I have tried index, match and vlookup. They only give answer for
two variables. Please help. Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Extracting value froma table

Hi,
Try this:

Enter as UDF function - for example put =XMATCH(A3,D1) in a cell for your
example.

From VBA:

MyAns=XMATCH(Range("A3"),Range("D1")

You will need to change DataRng and ColRng to suit your needs.

HTH


Function XMatch(ByVal rng1 As Range, ByVal rng2 As Range) As String

Dim lastrow As Long
Dim v() As Variant
Dim DataRng As Range, ColRng As Range

lastrow = Cells(Rows.Count, "A").End(xlUp).Row
i = 0
For r = 2 To lastrow ' <=== Create data for row matching
ReDim Preserve v(i)
v(i) = Cells(r, 1) & Cells(r, 2)
i = i + 1
Next r

rowVal = rng1.Value & rng1.Offset(0, 1).Value ' <=== Row indices
colVal = rng2.Value ' Column index
Set DataRng = Range("c2:z50") ' Data table
Set ColRng = Range("c1:z1") ' Column Range

If Application.And(Application.Match(rowVal, v, 0),
Application.Match(colVal, Range("C1:Z1"))) Then
XMatch = Application.Index(DataRng, Application.Match(rowVal, v, 0),
Application.Match(colVal, ColRng))
Else
XMatch = "Not found"
End If
End Function"KP" wrote:

I have a table with three variables. I need to extract data based on the
value of three variables. For example:

Column 1 Column2 Column3 Column4 and so on...
4 5
10 8 8-0.25 8-0.375
10 12 10-0.25 10-.0375
12 8 9-0.188 9-0.375
12 12 11-0.375 12-0.25

Based on the above data, I would like to extract data when column1 is 10,
column2 is 12 and value in the first row is 5. The answer should be
10-0.375. I have tried index, match and vlookup. They only give answer for
two variables. Please help. Thanks

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
Identifying numbers froma text Harish Excel Discussion (Misc queries) 5 November 24th 08 11:03 PM
Extracting Numbers froma Text String Jules Excel Worksheet Functions 7 August 1st 07 04:53 AM
Extracting a Single Worksheet froma Mutipage Workbook Tom Excel Discussion (Misc queries) 4 March 16th 06 04:17 PM
lookup value froma filtered list Eric Excel Worksheet Functions 4 July 15th 05 12:48 AM
Copying and Pasting froma Userform Richard Excel Programming 1 May 18th 04 09:20 AM


All times are GMT +1. The time now is 12:55 AM.

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"