Formula To Return TRUE If Text In Cell Is Either xxxx.xxx or 11-Digits

JuicyMusic

Board Regular
Joined
Jun 13, 2020
Messages
210
Office Version
  1. 365
Platform
  1. Windows
Hi gurus, I know the formula I'm asking for is not great...but I can't come up with anything else to solve my problem.
FYI - We have hundreds of 11-digit general ledger codes and 7-digit sub-ledger codes. I'm providing 1 example for each.


Formula needed: If the target cell contains this type of text 2007.030 (4 digits--a period--3 digits).....Then return this text: "Sub-Ledger Code for 16360045"
If the target cell contains this type of text 60070055600 w/ exactly 11 digits (no periods).....Then return this number 60070055600.

If target cell doesn't contain either of the above.....Then return something like..."Pls check GL coding".

Suggestions are welcome.
Thank you so much!
Juicy,
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hi gurus, I know the formula I'm asking for is not great...but I can't come up with anything else to solve my problem.
FYI - We have hundreds of 11-digit general ledger codes and 7-digit sub-ledger codes. I'm providing 1 example for each.


Formula needed: If the target cell contains this type of text 2007.030 (4 digits--a period--3 digits).....Then return this text: "Sub-Ledger Code for 16360045"
If the target cell contains this type of text 60070055600 w/ exactly 11 digits (no periods).....Then return this number 60070055600.

If target cell doesn't contain either of the above.....Then return something like..."Pls check GL coding".

Suggestions are welcome.
Thank you so much!
Juicy,

Perhaps this, though the second criteria, is it to return that number specifically, or if the format matches 11 digits without a period, to return the number itself?

Cell Formulas
RangeFormula
C1:C5C1=IF(AND(MID(A1,5,1)=".",LEN(A1)=8),"Sub-Ledger Code for 16360045",IF(AND(IFERROR(FIND(".",A1),1),LEN(A1)=11),"60070055600","Pls check GL coding"))
 
Upvote 0
Upvote 0
Perhaps this, though the second criteria, is it to return that number specifically, or if the format matches 11 digits without a period, to return the number itself?

Cell Formulas
RangeFormula
C1:C5C1=IF(AND(MID(A1,5,1)=".",LEN(A1)=8),"Sub-Ledger Code for 16360045",IF(AND(IFERROR(FIND(".",A1),1),LEN(A1)=11),"60070055600","Pls check GL coding"))
Yes, you are correct. If the target cells contains an 11-digit number, then the wanted result is that it returns itself. TY!
 
Upvote 0
Yes, you are correct. If the target cells contains an 11-digit number, then the wanted result is that it returns itself. TY!
Okay, then if you choose to use my solution, here is the proper version to return the number itself, otherwise Loki's solution looks perfectly suitable as well with that already taken into account.

Excel Formula:
=IF(AND(MID(A1,5,1)=".",LEN(A1)=8),"Sub-Ledger Code for 16360045",IF(AND(IFERROR(FIND(".",A1),1),LEN(A1)=11),A1,"Pls check GL coding"))
 
Upvote 0
could also try this
---------------------
Cell Formulas
RangeFormula
B1:B5B1=IFERROR(IFS(AND(LEN(TEXTBEFORE(TEXT(A1,"###0.000"),".",))=4,LEN(TEXTAFTER(TEXT(A1,"###0.000"),".",))=3),"Sub-Ledger Code for 16360045",LEN(A1)=11,A1),"Pls check GL coding")

Loki, I really like your suggestion since it accounts for typos's......but your formula's bring back "Pls Check GL Coding". Can you try again and see? Thanks!
 
Upvote 0
can you give me some examples where it's returning the wrong values?

currently it's returning:
• 4 digits"."3 digits= "Sub-Ledger Code for 16360045"
• 11 digits (no periods)= referenced number
• if neither= "Pls check GL coding" (this would include: blanks, 4+/- digits"."3 digits, not exactly 11 w/out ".")
as requested in the OP

however mine does not correctly return 4 digits"."3+/- digits, will get Sub-Ledger Code for 16360045
as shown below
multiple posts solutions-v3.xlsm
ABC
1inputresultformat
2600700556006007005560011
3123456789011234567890111
41234567890Pls check GL coding10
5123456789012Pls check GL coding12
62007.030Sub-Ledger Code for 163600454.3
71234.123Sub-Ledger Code for 163600454.3
8123.123Pls check GL coding3.3
912345.123Pls check GL coding5.3
10Pls check GL codingblank
111234.12Sub-Ledger Code for 163600454.2
121234.1234Sub-Ledger Code for 163600454.4
131234.1Sub-Ledger Code for 163600454.1
141234Sub-Ledger Code for 163600454.0
ifs dec or 11 digit
Cell Formulas
RangeFormula
B2:B14B2=IFERROR(IFS(AND(LEN(TEXTBEFORE(TEXT(A2,"###0.000"),".",))=4,LEN(TEXTAFTER(TEXT(A2,"###0.000"),".",))=3),"Sub-Ledger Code for 16360045",LEN(A2)=11,A2),"Pls check GL coding")
 
Last edited:
Upvote 0
however mine does not correctly return 4 digits"."3+/- digits, will get Sub-Ledger Code for 16360045
i may have solved that though, except 4digits.2digits is still returning "Sub-Ledger Code for 16360045" as it's adding a 0 at the end
---------------------
multiple posts solutions-v3.xlsm
ABC
1inputnew resultformat
2600700556006007005560011
3123456789011234567890111
41234567890Pls check GL coding10
5123456789012Pls check GL coding12
62007.030Sub-Ledger Code for 163600454.3 end 0
71234.123Sub-Ledger Code for 163600454.3
8123.123Pls check GL coding3.3
912345.123Pls check GL coding5.3
10Pls check GL codingblank
111234.120Sub-Ledger Code for 163600454.2
121234.1234Pls check GL coding4.4
131234.100Pls check GL coding4.1
141234.000Pls check GL coding4.0
ifs dec or 11 digit
Cell Formulas
RangeFormula
B2:B14B2=IFERROR(IFS(AND(LEN(TEXTBEFORE(TEXT(A2,"###0.000"),".",))=4,IF(OR(LEN(A2)<7,LEN(A2)>8),FALSE,LEN(TEXTAFTER(TEXT(A2,"###0.000"),".",))=3)),"Sub-Ledger Code for 16360045",LEN(A2)=11,A2),"Pls check GL coding")
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,624
Latest member
gregg777

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