Bank Reconciliation- Extracting Agreements

Bars03

New Member
Joined
May 12, 2015
Messages
18
Hi

I am working on a macro to speed up my bank reconciliation process. I am almost there but need a little help on extracting agreement numbers that should be contained within the narrative of the bank statement thus allowing me to clear against my general ledger transactions. The below data is a fake example of a bank statement I have pulled together.

The headers will populate columns A to M on my worksheet.

Within the narrative there will be seven digit Agreement numbers i.e. 8831773 and 9317014

Most of the time they tend to appear in the narrative of the cell with spaces before and after the agreement number. But this will not always be the case and sometimes they may be preceded/followed by text without any gaps.

I have a separate spreadsheet called Agreements which lists all the agreements on the system.

Is is possible to have a macro that will satisfactorily check the data in Column M on the bank statement spreadsheet and check if it contains an agreement that appears on the Agreements spreadsheet? If so it will need to populate column N on the bank statement spreadsheet with the agreement number or leave blank.


GROUPACC IDACCOUNT NOTYPEBANK CODECURRENTRY DATEAS ATAMOUNTTLA CODECHEQUE NOSTATUSDESCRIPTION
9029576220/07/1919GBP08/05/2015Close1STCCA CASTO 8831773 STOFrom: 77-66-44 19956666
9029576220/07/1982GBP08/05/2015Close6.9STCCCARLTON C 8836717 STOFrom: 60-00-50 71366714
9029576220/07/1982GBP08/05/2015Close8.28STCCJ BRAMLIN 9317014 STOFrom: 30-94-48 45026368
9029576220/07/1982GBP08/05/2015Close13.59STCCMR SAMUEL J COPPER 8817174 STOFrom: 55-51-28 61192205
9029576220/07/1982GBP08/05/2015Close20STCCMRS C ODUNLAMI 8868527 STOFrom: 60-05-02 48127798
9029576220/07/1982GBP08/05/2015Close21.76STCCRAQUEL BARKES 9325124STOFrom: 09-01-27 74256221
9029576220/07/1982GBP08/05/2015Close26.07STCCM MILES8860100 STOFrom: 30-91-79 16634560
9029576220/07/1982GBP08/05/2015Close40.99STCCGORDON KA 9717752 STOFrom: 55-10-31 17503013
9029576220/07/1982GBP08/05/2015Close46.32STCCM MILES 9321564 STOFrom: 30-91-79 16636960
9029576220/07/1982GBP08/05/2015Close55.96STCCMR SINGHER A8971947 STOFrom: 08-92-49 05124600
9029576220/07/1982GBP08/05/2015Close62.3STCCMR SINGHA8881333 STOFrom: 08-91-49 05523600
9029576220/07/1982GBP08/05/2015Close110STCCA DODD MR J TODD8870956 STOFrom: 11-16-70 00458341
9029576220/07/1982GBP08/05/2015Close98FPCC0OUNG RICHARDO L L 8876981 BGCFrom: 60-04-14 75024487

<tbody>
</tbody>


Thanks in Advance:LOL:
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Here's a UDF that will pull the 7-digit agreement number from col M entries. After you install the UDF it can be used like any worksheet function (see example below). Once you have extracted the 7-digit number it should be easy to see if there's a MATCH on the Agreements sheet.

Excel Workbook
MN
1DESCRIPTIONAgreement#
2A CASTO 8831773 STOFrom: 77-66-44 199566668831773
3CARLTON C 8836717 STOFrom: 60-00-50 713667148836717
4J BRAMLIN 9317014 STOFrom: 30-94-48 450263689317014
5MR SAMUEL J COPPER 8817174 STOFrom: 55-51-28 611922058817174
6MRS C ODUNLAMI 8868527 STOFrom: 60-05-02 481277988868527
7RAQUEL BARKES 9325124STOFrom: 09-01-27 742562219325124
8M MILES8860100 STOFrom: 30-91-79 166345608860100
9GORDON KA 9717752 STOFrom: 55-10-31 175030139717752
10M MILES 9321564 STOFrom: 30-91-79 166369609321564
11MR SINGHER A8971947 STOFrom: 08-92-49 051246008971947
12MR SINGHA8881333 STOFrom: 08-91-49 055236008881333
13A DODD MR J TODD8870956 STOFrom: 11-16-70 004583418870956
140OUNG RICHARDO L L 8876981 BGCFrom: 60-04-14 750244878876981
Sheet12


To install the UDF:
1. With your workbook active press Alt and F11 keys. This will open the VBE window.
2. In the project tree on the left of the VBE window, find your project and click on it.
3. On the VBE menu: Insert>Module
4. Copy the code from your browser window and paste it into the white space in the VBE window.
5. Close the VBE window and Save the workbook. If you are using Excel 2007 or a later version do a SaveAs and save it as a macro-enabled workbook (.xlsm file extension).
6. Press Alt+F8 keys to run the code
7. Make sure you have enabled macros whenever you open the file or the code will not run.
Code:
Function AgreementNum(S As String)
'Agreement numbers are 7 digits and may or may not be separated from rest of string S by spaces
'Assume, at most only one 7-digit number per string.
With CreateObject("VBScript.Regexp")
    .Global = True
    .Pattern = "(\d{7})"
    If .test(S) Then
        AgreementNum = .Execute(S)(0)
    Else
        AgreementNum = CVErr(xlErrNA)
    End If
End With
End Function
 
Upvote 0
This worked on your sample, see how it does on the rest:


Excel 2010
MN
1DESCRIPTION
2A CASTO 8831773 STOFrom: 77-66-44 199566668831773
3CARLTON C 8836717 STOFrom: 60-00-50 713667148836717
4J BRAMLIN 9317014 STOFrom: 30-94-48 450263689317014
5MR SAMUEL J COPPER 8817174 STOFrom: 55-51-28 611922058817174
6MRS C ODUNLAMI 8868527 STOFrom: 60-05-02 481277988868527
7RAQUEL BARKES 9325124STOFrom: 09-01-27 742562219325124
8M MILES8860100 STOFrom: 30-91-79 166345608860100
9GORDON KA 9717752 STOFrom: 55-10-31 175030139717752
10M MILES 9321564 STOFrom: 30-91-79 166369609321564
11MR SINGHER A8971947 STOFrom: 08-92-49 051246008971947
12MR SINGHA8881333 STOFrom: 08-91-49 055236008881333
13A DODD MR J TODD8870956 STOFrom: 11-16-70 004583418870956
140OUNG RICHARDO L L 8876981 BGCFrom: 60-04-14 750244878876981
Sheet8
Cell Formulas
RangeFormula
N2=TRIM(RIGHT(MID(M2,FIND("From",M2,1)-12,9),MAX(7,LEN(MID(M2,FIND("From",M2,1)-12,9))-1)))
 
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,839
Members
449,051
Latest member
excelquestion515

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