Looking up a value in data source, matching on another criteria and outputting a value from a third column

stovvy

New Member
Joined
Feb 12, 2018
Messages
10
I have the following query and cannot for the life of me get any kind of nested formula to work. What I require is it to look at cell A1 in Sheet 2 and in Sheet 1 look for that cell in Column A (which appears more than once), but then look at Column B for a zero and then take the value from Column C that corresponds and place it it Sheet 2 in Cell B1. I would then need it to find the same value, but this time 1 in Column B and then place Column C's figure in Sheet 2 cell C1. This needs to be repeated up to 6 times and for multiple lookups.

Sheet 1 Sheet 2
A B C A B C D E F G
1 Dave 0 15 1 Dave 15 13 12 9 7 5
2 Dave 2 12 2 Fred 3 6 8 13 15 17
3 Dave 5 5
4 Dave 1 13
5 Dave 3 9
6 Dave 4 7
7 Fred 5 17
8 Fred 3 13
9 Fred 2 8
10 Fred 4 15
11 Fred 1 6
12 Fred 0 3

Any help would be gratefully received

Thanks
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
 
Upvote 0
How about


Excel 2013/2016
ABCDEFGHIJKL
1012345
2Dave015Dave151312975
3Dave212Fred368131517
4Dave55
5Dave113
6Dave39
7Dave47
8Fred517
9Fred313
10Fred28
11Fred415
12Fred16
13Fred03
Lists
Cell Formulas
RangeFormula
G2{=IFERROR(INDEX($C$2:$C$13,MATCH(1,($A$2:$A$13=$F2)*($B$2:$B$13=G$1),0)),"")}
Press CTRL+SHIFT+ENTER to enter array formulas.


Also, you cannot show pictures that are on your computer. They would need to be uploaded to a share site.
 
Upvote 0
VBA alternative: You would need to insert a header row in Sheet1 so that the data starts in row 2. The macro assumes you are using 2 sheets with the result going to Sheet2.
Code:
Sub stovvy()
    Application.ScreenUpdating = False
    Dim LastRow As Long, srcWS As Worksheet, desWS As Worksheet, rName As Range
    Set srcWS = Sheets("Sheet1")
    Set desWS = Sheets("Sheet2")
    LastRow = srcWS.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    With srcWS.Sort
        .SortFields.Clear
        .SortFields.Add Key:=Range("A2:A" & LastRow), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        .SortFields.Add Key:=Range("B2:B" & LastRow), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        .SetRange Range("A1:D" & LastRow)
        .Header = xlGuess
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    For Each rName In desWS.Range("A1", desWS.Range("A" & desWS.Rows.Count).End(xlUp))
        With srcWS.Cells(1).CurrentRegion
            .AutoFilter 1, rName
            srcWS.Range("C2:C" & LastRow).SpecialCells(xlCellTypeVisible).Copy
            rName.Offset(0, 1).PasteSpecial Transpose:=True
            .AutoFilter
        End With
    Next rName
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,084
Messages
6,123,028
Members
449,092
Latest member
ikke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top