Prefer Formula Solution to lookup value

Anne Troy

MrExcel MVP
Joined
Feb 18, 2002
Messages
2,632
Office Version
  1. 365
Platform
  1. Windows
Suppose I have these two columns, which are the employee and the amount they owe. In columns to the left (not shown below), I'm tracking payroll deductions/advances.

John 600
Judy 300
John 500
Judy 250
Jade 1000
Jade 500
John 300
Judy 600

I want to have another set of columns to show me the current amount owed, like:

John 300
Judy 600
Jade 500

Because the amount they owe will always be the last amount at the bottom of the column. It's not necessarily the lowest amount, like MIN, so how do I get the last amount for a given name?

I would call Bill directly, but he's just so important now. LOL

Thanks in advance!!
 
Last edited:

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
the code gets a name then searches from bottom up.

Code:
Public Sub Test()
MsgBox WhatDoTheyOwe("John")
End Sub


Function WhatDoTheyOwe(ByVal pvName)
Range("A1").Select
Selection.End(xlDown).Select  'goto bottom
'begin searching from bottom
While ActiveCell.Row > 1
  If pvName = ActiveCell.Value Then
     WhatDoTheyOwe = ActiveCell.Offset(0, 1).Value
     Exit Function
  End If
  
  ActiveCell.Offset(-1, 0).Select  'next row up
Wend
End Function

you should really learn Microsoft Access. It is the prefect tool for doing this sort of thing.
 
Last edited:
Upvote 0
maybe something like...

Unknown
ABCDE
2John600John300
3Judy300Judy600
4John500Jade500
5Judy250
6Jade1000
7Jade500
8John300
9Judy600

<tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
E2=LOOKUP(2,1/($A$2:$A$9=D2),$B$2:$B$9)

<tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
Sorry. I have about 8 employees who get advances. I'm not building a database for it. I have one, but I'm not doing payroll with it.

I'm not sure how I would do this as a formula in multiple cells.

Thanks for your time!
 
Upvote 0
maybe something like...

Unknown
ABCDE
2John600John300
3Judy300Judy600
4John500Jade500
5Judy250
6Jade1000
7Jade500
8John300
9Judy600

<tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
E2=LOOKUP(2,1/($A$2:$A$9=D2),$B$2:$B$9)

<tbody>
</tbody>

<tbody>
</tbody>

That's beautiful, Weazel. I didn't even get a chance to give my sample file link. www.annetroy.com/mrexcel/Sample.xlsx
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,626
Members
449,093
Latest member
catterz66

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