execute a different formula basis cell value

PrashanthKumar123

New Member
Joined
May 1, 2021
Messages
38
hi - I am working on a text string project.

Few sample keywords include -

IMPS OUTWARD
PURCHASE SUBJECT
INTERCITY ECS

In the below table, col A has few sample entries in my input data. Col B recognizes the string based on the above keywords. My next step is to execute a formula based on Col B cell values, i.e., a different formula for "IMPS OUTWARD", another for "PURCHASE SUBJECT and another for "INTERCITY ECS". Presently, I have a nested if to do this, but as my list of keywords increases, I worry if should look at a better way.

IMPS OUTWARD ORG UPI To XXXXXXXX6607@icic0000183.ifsc.npci,REF NO - 024519820714, UPIIMPS OUTWARDFormula for IMPS Outward
IMPS OUTWARD ORG UPI To paytmqrXXXXXXXXX1015tmy4w7ksb2r@paytm,REF NO - 024620963921, UPIIMPS OUTWARDFormula for IMPS Outward
IMPS OUTWARD ORG UPI To umakumpatla70@okhdfcbank,REF NO - 024817061778, UPIIMPS OUTWARDFormula for IMPS Outward
PURCHASE SUBJECT: MCUPOS 02SEP1156 Card no.: XXXXXXXXXX 02SEP20 115640 Innovative Retail Conc\BIGBASK Ref: 024616394551PURCHASE SUBJECTFormula for Purchase Subject
IMPS OUTWARD ORG UPI To qXXXX0411@ybl,REF NO - 024820419752, UPIIMPS OUTWARDFormula for IMPS Outward
INTERCITY ECS. PAID NACH:Paid to HDFCLTD:HDFC01651000012196:HDFC BANK LTD Refno:262549161 -HDFC BANKINTERCITY ECSFormula for Intercity ECS
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hi PrashantKumar1,

You can't interpret formula from cell contents without using VBA. If you can put the formulae as CHOOSE options then this would work:

PrashanthKumar1.xlsx
ABCDEFGH
1IMPS OUTWARD ORG UPI To XXXXXXXX6607@icic0000183.ifsc.npci,REF NO - 024519820714, UPIIMPS OUTWARD2StringFormula Number
2IMPS OUTWARD ORG UPI To paytmqrXXXXXXXXX1015tmy4w7ksb2r@paytm,REF NO - 024620963921, UPIIMPS OUTWARD2IMPS OUTWARD1
3IMPS OUTWARD ORG UPI To umakumpatla70@okhdfcbank,REF NO - 024817061778, UPIIMPS OUTWARD2PURCHASE SUBJECT2
4PURCHASE SUBJECT: MCUPOS 02SEP1156 Card no.: XXXXXXXXXX 02SEP20 115640 Innovative Retail Conc\BIGBASK Ref: 024616394551PURCHASE SUBJECT4INTERCITY ECS3
5IMPS OUTWARD ORG UPI To qXXXX0411@ybl,REF NO - 024820419752, UPIIMPS OUTWARD2
6INTERCITY ECS. PAID NACH:Paid to HDFCLTD:HDFC01651000012196:HDFC BANK LTD Refno:262549161 -HDFC BANKINTERCITY ECS6
7 
Sheet1
Cell Formulas
RangeFormula
C1:C7C1=IFERROR(CHOOSE(INDEX($H$2:$H$99,MATCH(B1,$G$2:$G$99,0)),1+1,2+2,3+3),"")
 
Upvote 0
hi Toadstool, thank you for the help! Formula 1, 2 and 3 are not static in my case, but actually a search formula on corresponding row element in Col A. Would CHOOSE work here?

If no, could you also help share what the VBA response might look like?

thanks in advance!
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
In that case if you create a list of your values you can use choose like
+Fluff 1.xlsm
ABCDE
1IMPS OUTWARDIMPS OUTWARD ORG UPI To XXXXXXXX6607@icic0000183.ifsc.npci,REF NO - 024519820714, UPIIMPS OUTWARDimps formula
2PURCHASE SUBJECTIMPS OUTWARD ORG UPI To paytmqrXXXXXXXXX1015tmy4w7ksb2r@paytm,REF NO - 024620963921, UPIIMPS OUTWARDimps formula
3INTERCITY ECSIMPS OUTWARD ORG UPI To umakumpatla70@okhdfcbank,REF NO - 024817061778, UPIIMPS OUTWARDimps formula
4PURCHASE SUBJECT: MCUPOS 02SEP1156 Card no.: XXXXXXXXXX 02SEP20 115640 Innovative Retail Conc\BIGBASK Ref: 024616394551PURCHASE SUBJECTpurchase formula
5IMPS OUTWARD ORG UPI To qXXXX0411@ybl,REF NO - 024820419752, UPIIMPS OUTWARDimps formula
6INTERCITY ECS. PAID NACH:Paid to HDFCLTD:HDFC01651000012196:HDFC BANK LTD Refno:262549161 -HDFC BANKINTERCITY ECSinter formula
7
List2
Cell Formulas
RangeFormula
E1:E6E1=CHOOSE(MATCH(D1,$A$1:$A$3,0),"imps formula","purchase formula","inter formula")


Just replace the "imps formula" etc, with your actual formulae.
 
Upvote 0
hi Toadstool, thank you for the help! Formula 1, 2 and 3 are not static in my case, but actually a search formula on corresponding row element in Col A. Would CHOOSE work here?

If no, could you also help share what the VBA response might look like?

thanks in advance!
Yes, CHOOSE can use different formulae and not just static entries. e.g. here I use three different formulae to extract the reference numbers

PrashanthKumar2.xlsx
ABCDEFGH
1IMPS OUTWARD ORG UPI To XXXXXXXX6607@icic0000183.ifsc.npci,REF NO - 024519820714, UPIIMPS OUTWARD024519820714StringFormula Number
2IMPS OUTWARD ORG UPI To paytmqrXXXXXXXXX1015tmy4w7ksb2r@paytm,REF NO - 024620963921, UPIIMPS OUTWARD024620963921IMPS OUTWARD1
3IMPS OUTWARD ORG UPI To umakumpatla70@okhdfcbank,REF NO - 024817061778, UPIIMPS OUTWARD024817061778PURCHASE SUBJECT2
4PURCHASE SUBJECT: MCUPOS 02SEP1156 Card no.: XXXXXXXXXX 02SEP20 115640 Innovative Retail Conc\BIGBASK Ref: 024616394551PURCHASE SUBJECT024616394551INTERCITY ECS3
5IMPS OUTWARD ORG UPI To qXXXX0411@ybl,REF NO - 024820419752, UPIIMPS OUTWARD024820419752
6INTERCITY ECS. PAID NACH:Paid to HDFCLTD:HDFC01651000012196:HDFC BANK LTD Refno:262549161 -HDFC BANKINTERCITY ECS262549161
7
Sheet1 (2)
Cell Formulas
RangeFormula
C1:C6C1=IFERROR(CHOOSE(INDEX($H$2:$H$99,MATCH(B1,$G$2:$G$99,0)),SUBSTITUTE(RIGHT(A1,LEN(A1)-SEARCH("REF NO -",A1)-8),", UPI",""),RIGHT(A1,LEN(A1)-SEARCH("Ref: ",A1)-4),MID(A1,SEARCH("Refno:",A1)+6,(SEARCH(" ",A1,SEARCH("Refno:",A1)+6))-(SEARCH("Refno:",A1)+6)+1)),"")


If using VBA you may look at the Evaluate function.
 
Upvote 0
hi fluff and toadstool, thanks a ton for your assistance. I tried the following steps and found partial success but struggle with at one step. Can you help check and tell me how I can fix?

Step 1: This is a sample of my keyword and formula table. There are more keywords and formula combinations, but this is to illustrate.


KeywordsFormula
IMPS OUTWARDIF(SUMPRODUCT(--ISNUMBER(SEARCH(SMB_Keywords,Table1[@Description])))>0, TRIM(RIGHT(SUBSTITUTE(Table1[@Description],",",REPT(" ",100)),100)),MID(Table1[@Description],SEARCH("ORG UPI TO",Table1[@Description])+11,SEARCH(",",Table1[@Description])-SEARCH("ORG UPI TO",Table1[@Description])-11))
PURCHASE SUBJECTMID(table1[@Description],SEARCH("4857",table1[@Description])+20,SEARCH("Ref",table1[@Description])-SEARCH("4857",table1[@Description])-20)
INTERCITY ECSMID(Table1[@Description],SEARCH("Paid to",Table1[@Description])+8, SEARCH("Refno",Table1[@Description])-SEARCH("Paid to",Table1[@Description])-8)

Table 1 is the table that I created for my input data. Description is the column.

Step 2: I also created a name range with =EVALUATE(VLOOKUP(Table1[@[Payment Type]],Definitions!$A$1:$C$7,3,0)). This works well. Essentially, this looks up the keyword (Col 2 in the below table) and executes the corresponding formula from the table in Step 1.

DescriptionKeywordExpected OutcomeActual Outcome
IMPS OUTWARD ORG UPI To XXXXXXXX6607@icic0000183.ifsc.npci,REF NO - 024519820714, UPIIMPS OUTWARDXXXXXXXX6607@icic0000183.ifsc.npci
#VALUE!​
IMPS OUTWARD ORG UPI To paytmqrXXXXXXXXX1015tmy4w7ksb2r@paytm,REF NO - 024620963921, UPIIMPS OUTWARDUPI
#VALUE!​
IMPS OUTWARD ORG UPI To umakumpatla70@okhdfcbank,REF NO - 024817061778, UPIIMPS OUTWARDumakumpatla70@okhdfcbank
#VALUE!​
PURCHASE SUBJECT: MCUPOS 02SEP1156 Card no.: 5125XXX2XXXX4857 02SEP20 115640 Innovative Retail Conc\BIGBASK Ref: 024616394551PURCHASE SUBJECTInnovative Retail Conc\BIGBASKInnovative Retail Conc\BIGBASK
IMPS OUTWARD ORG UPI To qXXXX0411@ybl,REF NO - 024820419752, UPIIMPS OUTWARDUPI
#VALUE!​
IMPS OUTWARD ORG UPI To paytmqrXXXXXXXXX1011xf41l1xin30@paytm,REF NO - 024820436772, UPIIMPS OUTWARDUPI
#VALUE!​
IMPS OUTWARD ORG UPI To paytmqrXXXXXXXXXX0118edlmk3ewmx@paytm,REF NO - 024820599339, UPIIMPS OUTWARDUPI
#VALUE!​
INTERCITY ECS. PAID NACH:Paid to HDFCLTD:HDFC01651000012196:HDFC BANK LTD Refno:262549161 -HDFC BANKINTERCITY ECSHDFCLTD:HDFC01651000012196:HDFC BANK LTDHDFCLTD:HDFC01651000012196:HDFC BANK LTD

Col 3 is the expected outcome. Interestingly, this works well for keywords PURCHASE SUBJECT and INTERCITY ECS. But for IMPS OUTWARD, I am unable to figure what the issue is?

Do you see what I might be doing wrong?
 
Upvote 0
What is SMB_Keywords?
The reason the formula doesn't work is that it's more than 255 characters in length
 
Upvote 0
Solution

Forum statistics

Threads
1,214,805
Messages
6,121,665
Members
449,045
Latest member
Marcus05

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