Need to Extract Text

hardeep.kanwar

Well-known Member
Joined
Aug 13, 2008
Messages
693
Hi

I want to extract the Text after PO mentioned in below text

Note: All PO number are 14 Digit Alphanumaric

[TABLE="width: 0"]
<tbody>[TR]
[TD]1
[/TD]
[TD]BEING BILL NO JG/18-19/251 AGAINST HERO'S PO NO-CHN:18-19:1517, PO DATE-6-8-2018,ACTIVITY TOWARDS -LOAN MELA (DOWN PAYMENT RS./-1) BARNALA, DURATION-22/06/2018 TO 24/6/2018
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]BEING BILL NO JG/18-19/250 AGAINST HERO'S PO NO-CHN:18-19:1518,PO DATE-6-8-2018,ACTIVITY-(5)-LOAN MELA AT OPP. BHAGWAN SUGAR MILL, DHURI, DURATION-25/07/2018 TO 27/7/2018
[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]BEING BILL NO JG/18-19/252 AGAINST HERO'S PO -CHN:18-19:1519, PO DATE-06-Aug-18, ACTIVITY TOWARDS -(5) LOAN MELA (DOWN PAYMENT RS./-1) SANGRUR, DURATION-22/06/2018 TO 24/6/2018.
[/TD]
[/TR]
[TR]
[TD]4
[/TD]
[TD]Being Invoice no A02-2018 dated 04/04/2018 towords activity of Outdoor Display And Hording against PO BPL:17-18:4095\RB\017 Dated 03/04/2018
[/TD]
[/TR]
[TR]
[TD]5
[/TD]
[TD]Being Invoice no A01-2018 dated 04/04/2018 towords activity of Outdoor Display And Hording against PO BPL:17-18:3450\RBA\015 Dated 03/04/2018
[/TD]
[/TR]
</tbody>[/TABLE]

Thanks in Advance

Hardeep Kanwar
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Hi,

See if this helps:


Book1
AB
1BEING BILL NO JG/18-19/251 AGAINST HERO'S PO NO-CHN:18-19:1517, PO DATE-6-8-2018,ACTIVITY TOWARDS -LOAN MELA (DOWN PAYMENT RS./-1) BARNALA, DURATION-22/06/2018 TO 24/6/2018CHN:18-19:1517
2BEING BILL NO JG/18-19/250 AGAINST HERO'S PO NO-CHN:18-19:1518,PO DATE-6-8-2018,ACTIVITY-(5)-LOAN MELA AT OPP. BHAGWAN SUGAR MILL, DHURI, DURATION-25/07/2018 TO 27/7/2018CHN:18-19:1518
3BEING BILL NO JG/18-19/252 AGAINST HERO'S PO -CHN:18-19:1519, PO DATE-06-Aug-18, ACTIVITY TOWARDS -(5) LOAN MELA (DOWN PAYMENT RS./-1) SANGRUR, DURATION-22/06/2018 TO 24/6/2018.CHN:18-19:1519
4Being Invoice no A02-2018 dated 04/04/2018 towords activity of Outdoor Display And Hording against PO BPL:17-18:4095\RB\017 Dated 03/04/2018BPL:17-18:4095
5Being Invoice no A01-2018 dated 04/04/2018 towords activity of Outdoor Display And Hording against PO BPL:17-18:3450\RBA\015 Dated 03/04/2018BPL:17-18:3450
Sheet211
Cell Formulas
RangeFormula
B1=SUBSTITUTE(MID(TRIM(SUBSTITUTE(SUBSTITUTE(MID(A1,FIND("PO",A1),255),"NO",""),"-"," ")),4,14)," ","-")


Formula copied down.
 
Upvote 0
Hi,

try this:

Code:
for i = 1 to cells(rows.count, 1).end(xlup).row
    for b = 1 to len(cells(i, 1) - 14
        if mid(cells(i, 1), b, 14) like "[A-Z][A-Z][A-Z] ##-## ####" then 
            cells(i,2) = mid(cells(i, 1),b+14)
        end if
    next b
next i

(not testet)

regards
 
Upvote 0
Hi

Could you pls tell me how to use this code?


Hi,

try this:

Code:
for i = 1 to cells(rows.count, 1).end(xlup).row
    for b = 1 to len(cells(i, 1) - 14
        if mid(cells(i, 1), b, 14) like "[A-Z][A-Z][A-Z] ##-## ####" then 
            cells(i,2) = mid(cells(i, 1),b+14)
        end if
    next b
next i

(not testet)

regards
 
Upvote 0
Hi

Thanks for the Formula,many cases it works,but some cases its not working (due to format), not coz of formula

Thanks again


Hi,

See if this helps:

AB
BEING BILL NO JG/18-19/251 AGAINST HERO'S PO NO-CHN:18-19:1517, PO DATE-6-8-2018,ACTIVITY TOWARDS -LOAN MELA (DOWN PAYMENT RS./-1) BARNALA, DURATION-22/06/2018 TO 24/6/2018CHN:18-19:1517
BEING BILL NO JG/18-19/250 AGAINST HERO'S PO NO-CHN:18-19:1518,PO DATE-6-8-2018,ACTIVITY-(5)-LOAN MELA AT OPP. BHAGWAN SUGAR MILL, DHURI, DURATION-25/07/2018 TO 27/7/2018CHN:18-19:1518
BEING BILL NO JG/18-19/252 AGAINST HERO'S PO -CHN:18-19:1519, PO DATE-06-Aug-18, ACTIVITY TOWARDS -(5) LOAN MELA (DOWN PAYMENT RS./-1) SANGRUR, DURATION-22/06/2018 TO 24/6/2018.CHN:18-19:1519
Being Invoice no A02-2018 dated 04/04/2018 towords activity of Outdoor Display And Hording against PO BPL:17-18:4095\RB\017 Dated 03/04/2018BPL:17-18:4095
Being Invoice no A01-2018 dated 04/04/2018 towords activity of Outdoor Display And Hording against PO BPL:17-18:3450\RBA\015 Dated 03/04/2018BPL:17-18:3450

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: center"]2[/TD]

[TD="align: center"]3[/TD]

[TD="align: center"]4[/TD]

[TD="align: center"]5[/TD]

</tbody>
Sheet211

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]B1[/TH]
[TD="align: left"]=SUBSTITUTE(MID(TRIM(SUBSTITUTE(SUBSTITUTE(MID(A1,FIND("PO",A1),255),"NO",""),"-"," ")),4,14)," ","-")[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]



Formula copied down.
 
Upvote 0
Based on your sample data ..

Excel Workbook
AB
1BEING BILL NO JG/18-19/251 AGAINST HERO'S PO NO-CHN:18-19:1517, PO DATE-6-8-2018,ACTIVITY TOWARDS -LOAN MELA (DOWN PAYMENT RS./-1) BARNALA, DURATION-22/06/2018 TO 24/6/2018CHN:18-19:1517
2BEING BILL NO JG/18-19/250 AGAINST HERO'S PO NO-CHN:18-19:1518,PO DATE-6-8-2018,ACTIVITY-(5)-LOAN MELA AT OPP. BHAGWAN SUGAR MILL, DHURI, DURATION-25/07/2018 TO 27/7/2018CHN:18-19:1518
3BEING BILL NO JG/18-19/252 AGAINST HERO'S PO -CHN:18-19:1519, PO DATE-06-Aug-18, ACTIVITY TOWARDS -(5) LOAN MELA (DOWN PAYMENT RS./-1) SANGRUR, DURATION-22/06/2018 TO 24/6/2018.CHN:18-19:1519
4Being Invoice no A02-2018 dated 04/04/2018 towords activity of Outdoor Display And Hording against PO BPL:17-18:4095\RB\017 Dated 03/04/2018BPL:17-18:4095
5Being Invoice no A01-2018 dated 04/04/2018 towords activity of Outdoor Display And Hording against PO BPL:17-18:3450\RBA\015 Dated 03/04/2018BPL:17-18:3450
Sheet1



If this doesn't work because of different possible texts, could we see those variations and the expected results from them?
 
Upvote 0
If you are looking for a vba solution, then you could try this user-defined function. To implement ..
1. Right click the sheet name tab and choose "View Code".
2. In the Visual Basic window use the menu to Insert|Module
3. Copy and Paste the code below into the main right hand pane that opens at step 2.
4. Close the Visual Basic window.
5. Enter the formula as shown in the screen shot below and copy down.
6. Your workbook will need to be saved as a macro-enabled workbook (*.xlsm)

Code:
Function PO(s As String) As String
  Static RX As Object
  
  If RX Is Nothing Then Set RX = CreateObject("VBScript.RegExp")
  RX.Pattern = "[A-Z]{3}:\d{2}\-\d{2}:\d{4}"
  If RX.Test(s) Then PO = RX.Execute(s)(0)
End Function

Excel Workbook
AB
1BEING BILL NO JG/18-19/251 AGAINST HERO'S PO NO-CHN:18-19:1517, PO DATE-6-8-2018,ACTIVITY TOWARDS -LOAN MELA (DOWN PAYMENT RS./-1) BARNALA, DURATION-22/06/2018 TO 24/6/2018CHN:18-19:1517
2BEING BILL NO JG/18-19/250 AGAINST HERO'S PO NO-CHN:18-19:1518,PO DATE-6-8-2018,ACTIVITY-(5)-LOAN MELA AT OPP. BHAGWAN SUGAR MILL, DHURI, DURATION-25/07/2018 TO 27/7/2018CHN:18-19:1518
3BEING BILL NO JG/18-19/252 AGAINST HERO'S PO -CHN:18-19:1519, PO DATE-06-Aug-18, ACTIVITY TOWARDS -(5) LOAN MELA (DOWN PAYMENT RS./-1) SANGRUR, DURATION-22/06/2018 TO 24/6/2018.CHN:18-19:1519
4Being Invoice no A02-2018 dated 04/04/2018 towords activity of Outdoor Display And Hording against PO BPL:17-18:4095\RB\017 Dated 03/04/2018BPL:17-18:4095
5Being Invoice no A01-2018 dated 04/04/2018 towords activity of Outdoor Display And Hording against PO BPL:17-18:3450\RBA\015 Dated 03/04/2018BPL:17-18:3450
Sheet2
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,304
Members
452,633
Latest member
DougMo

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