Latest Data pull-up from the corresponding date

Sunil Pinto

New Member
Joined
Jul 31, 2024
Messages
20
Office Version
  1. 2016
Can you please tell me if anyone can solve this puzzle?

Please refer to the below data

NameDateAdvanceBillBalance
A
1 Feb 2024​
1,000250750
B
1 Feb 2024​
2,0002751,725
A
10 Feb 2024​
750350400
C
10 Feb 2024​
2,5004502,050
D
14 Feb 2024​
1,8005501,250
C
15 Feb 2024​
2,0503001,750
B
1 Mar 2024​
1,7253001,425
D
9 Mar 2024​
1,250400850
A
1 Apr 2024​
400100300
B
1 Apr 2024​
1,4253501,075
D
5 Apr 2024​
850350500
C
27 Apr 2024​
1,7503501,400
A
1 May 2024​
300300-
C
15 May 2024​
1,400500900
D
19 May 2024​
500200300
B
1 Jun 2024​
1,075600475
C
19 Jun 2024​
900250650
D
23 Jun 2024​
300300-
C
25 Jun 2024​
650150500
B
10 Jul 2024​
475475-
C
27 Oct 2024​
500500-

In Cell "H4" I needed advanced balance if I entered the date in "G4"

If H4=29/2/2024, result in G4= 5,125 (Details of workings are below for your reference.
29 Feb 2024​
5,125.00(A-400, B-1,725,C-1,750,D-1,250)
31 Mar 2024​
4,425.00(A-400,B-1425,C1750,D-850)
30 Apr 2024​
3,275.00(A-300,B-1075,C-1400,D-500)
31/05/2024​
2,275.00(A-0,B-1075,C-900,D-300)
30/06/2024​
975.00(A-0,B-475,C-500,D-0)
31/07/2024​
500.00(A-0,B-0,C-500,D-0)
31/08/2024​
500.00(A-0,B-0,C-500,D-0)
30/09/2024​
500.00(A-0,B-0,C-500,D-0)
31/10/2024​
-(A-0,B-0,C-0,D-0)


Thanks a lot in advance whoever the expert fixes this task


Regards,

Sunil PInto
 

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.
Well, its an absolutely brutal formula, but it appears to work. Don't ask me how it works, as I was only taught the theory this morning by @Fluff :)

I'm unclear (due to the way you wrote your post) if your date went in 'G' or 'H' - so if I've got it inverted, you can switch the H's & G's in the formula...

Good luck
cheers
Rob

Book1
ABCDEFGH
1NameDateAdvanceBillBalance28/02/20245125
2A01/02/20241,000250750
3B01/02/20242,0002751,725
4A10/02/2024750350400
5C10/02/20242,5004502,050
6D14/02/20241,8005501,250
7C15/02/20242,0503001,750
8B01/03/20241,7253001,425
9D09/03/20241,250400850
10A01/04/2024400100300
11B01/04/20241,4253501,075
12D05/04/2024850350500
13C27/04/20241,7503501,400
14A01/05/2024300300-
15C15/05/20241,400500900
16D19/05/2024500200300
17B01/06/20241,075600475
18C19/06/2024900250650
19D23/06/2024300300-
20C25/06/2024650150500
21B10/07/2024475475-
22C27/10/2024500500-
23
24
Sheet1
Cell Formulas
RangeFormula
H1H1=INDEX($A$1:INDEX($E:$E,MATCH(INDEX(B:B,MATCH(G1,B:B,1)),B:B,0)),LOOKUP(2,1/($A$1:INDEX($E:$E,MATCH(INDEX(B:B,MATCH(G1,B:B,1)),B:B,0))="A"),ROW($A$1:INDEX($E:$E,MATCH(INDEX(B:B,MATCH(G1,B:B,1)),B:B,0)))-ROW(A1)+1),5)+INDEX($A$1:INDEX($E:$E,MATCH(INDEX(B:B,MATCH(G1,B:B,1)),B:B,0)),LOOKUP(2,1/($A$1:INDEX($E:$E,MATCH(INDEX(B:B,MATCH(G1,B:B,1)),B:B,0))="B"),ROW($A$1:INDEX($E:$E,MATCH(INDEX(B:B,MATCH(G1,B:B,1)),B:B,0)))-ROW(A1)+1),5)+INDEX($A$1:INDEX($E:$E,MATCH(INDEX(B:B,MATCH(G1,B:B,1)),B:B,0)),LOOKUP(2,1/($A$1:INDEX($E:$E,MATCH(INDEX(B:B,MATCH(G1,B:B,1)),B:B,0))="C"),ROW($A$1:INDEX($E:$E,MATCH(INDEX(B:B,MATCH(G1,B:B,1)),B:B,0)))-ROW(A1)+1),5)+INDEX($A$1:INDEX($E:$E,MATCH(INDEX(B:B,MATCH(G1,B:B,1)),B:B,0)),LOOKUP(2,1/($A$1:INDEX($E:$E,MATCH(INDEX(B:B,MATCH(G1,B:B,1)),B:B,0))="D"),ROW($A$1:INDEX($E:$E,MATCH(INDEX(B:B,MATCH(G1,B:B,1)),B:B,0)))-ROW(A1)+1),5)
 
Upvote 0
Solution
Dear All,
In above formula names of "A" Columns are integrated within the formula as "A", "B","C","D". Actually this is made me as obstacle's to use this formula. In my actual data, which contain large number of names and I not able to integrate within the formula.

Can any body help me to further develop the above formula

Thanks & Regards,

Sunil Pinto
 
Upvote 0
vba, if you like
to the sheet module
1) right click on the sheet tab and [view code]
2) paste the following code and hit Alt + F11 to go back to Excel
Code will run when G4 is changed.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim a, i&, dic As Object
    If Target.Address(0, 0) <> "G4" Then Exit Sub
    Application.EnableEvents = False
    Target(, 2).ClearContents
    If IsDate(Target) Then
        Set dic = CreateObject("Scripting.Dictionary")
        a = [a1].CurrentRegion.Value
        For i = UBound(a, 1) To 1 Step -1
            If (a(i, 2) <= Target) Then
                If Not dic.exists(a(i, 1)) Then dic(a(i, 1)) = IIf(a(i, 5) = "-", 0, a(i, 5))
            End If
        Next
        Target(, 2) = Application.Sum(dic.items)
    End If
    Application.EnableEvents = True
End Sub
 
Upvote 0
Or if you can look for the names one at a time, you can type the relevant name into a cell, say Q1 and change the "A" to =Q1.

then you can remove the other 75% of my formula for B, C and D references.

Rgds
Rob
 
Upvote 0
Then of course the other option if its a BIG problem would be to upgrade yourself from Excel 2016 to O365, as this brings many new formulas we could use to solve your problem in an easier way.

Rob
 
Upvote 0

Forum statistics

Threads
1,223,936
Messages
6,175,499
Members
452,649
Latest member
mr_bhavesh

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