Excel IF Formula & Remove Substring

miva0601

New Member
Joined
Mar 31, 2015
Messages
33
Hello,
Could someone please help me with the IF statement in column Q? The formula should be If Column J is "Y" then remove substring "HM" from column P. The formula I'm trying is also deleting everything after the substring and if the substring doesn't exist then it's giving me #VALUE!

APCI Admin Fee D PPA - 05.15.22 Detail.xlsx
ABCDEFGHIJKLMNOPQR
1YearMonthDateAccount #Concatenate (Date & Account #)BPRGPRGroup BPRGroup GPRGCRHMWaiverMissed CriteriaDistrictSFDC Last Modified (Approval Date)StatusSFDC WaiversFormulaExpected Result
22022011/1/20225145884456251458895.45089.37015.530YGPR101100Apr-22FALSEGPR HMGPR GPR
32022011/1/20229955834456299558375.00075.00015.090YBPR GPR101100Apr-22FALSEBPR HM GPRBPR BPR GPR
42022022/1/20227656294459376562997.09086.0000.000 YGPR101100Apr-22FALSEBPR#VALUE!BPR
52022022/1/20227656244459376562487.00087.0000.000 NGPR101100Apr-22FALSEBPR GPR HMBPR GPR HMBPR GPR HM
Sheet1
Cell Formulas
RangeFormula
Q2:Q5Q2=IF(J2="Y", LEFT(P2,SEARCH("HM",P2)-1), P2)
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
How about
Excel Formula:
=IF(J2="Y",SUBSTITUTE(P2,"HM ",""),P2)
 
Upvote 0
How about
Excel Formula:
=IF(J2="Y",SUBSTITUTE(P2,"HM ",""),P2)
It works for rows 3 and 4 but not for row 1:

APCI Admin Fee D PPA - 05.15.22 Detail.xlsx
ABCJKLMNOPQR
1YearMonthDateAccount #HMWaiverMissed CriteriaDistrictSFDC Last Modified (Approval Date)StatusSFDC WaiversFormulaExpected Result
22022011/1/2022514588YGPR101100Apr-22FALSEGPR HMGPR HMGPR
32022011/1/2022995583YBPR GPR101100Apr-22FALSEBPR HM GPRBPR GPRBPR GPR
42022022/1/2022765629YGPR101100Apr-22FALSEBPRBPRBPR
52022022/1/2022765624NGPR101100Apr-22FALSEBPR GPR HMBPR GPR HMBPR GPR HM
Sheet1
Cell Formulas
RangeFormula
Q2:Q5Q2=IF(J2="Y",SUBSTITUTE(P2,"HM ",""),P2)
 
Upvote 0
Ok, how about
Excel Formula:
=IF(J2="Y",TRIM(SUBSTITUTE(P2,"HM","")),P2)
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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