Editing large text cells

Manolocs

Active Member
Joined
Mar 28, 2008
Messages
340
Hello, I am wondering if there is a way to check a list of columns for a missing close parenthesis, I mean there is an open parenthesis, without a close ou vice versa.
Thanks in advance.
 
Last edited:

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
If your column is in A:A starting A1,

=IFERROR((IF(FIND("(",A1)>0,"")),"( Missing")&IFERROR((IF(FIND(")",A1)>0,""))," ) Missing")
 
Upvote 0
If your column is in A:A starting A1,

=IFERROR((IF(FIND("(",A1)>0,"")),"( Missing")&IFERROR((IF(FIND(")",A1)>0,""))," ) Missing")

Hi W8253, If the cell is empty or with any text without the "()" the return is "(missing) Missing" It would be better for me if only look for open or close parenthesis.
;)
 
Upvote 0
Hi W8253, If the cell is empty or with any text without the "()" the return is "(missing) Missing" It would be better for me if only look for open or close parenthesis.
;)


=CONCATENATE(IF(A1="","",IFERROR(IF(FIND("(",A1)>0,""),"Open missing ")),IF(A1="","",IFERROR(IF(FIND(")",A1)>0,""),"Close missing")))

Does this work?
 
Upvote 0
if there is no parenthesis at all still return the "Open missing Close missing"
the idea is to show only if it is missing the close if there is an open parenthesis and vice versa.
;)
 
Upvote 0
Give this a try:

=LOOKUP(SIGN(LEN(SUBSTITUTE(A1,"(",""))-LEN(SUBSTITUTE(A1,")",""))),{-1,0,1},{"Missing )","","Missing ("})
 
Last edited:
Upvote 0
Give this a try:

=LOOKUP(SIGN(LEN(SUBSTITUTE(A1,"(",""))-LEN(SUBSTITUTE(A1,")",""))),{-1,0,1},{"Missing )","","Missing ("})
There is one problem your formula, it will not identify a backward matching pair (it will return the empty text string "" for that condition). What I mean by backward matching is, in its simplest form (you can ugly it up by adding several properly matching pairs)...

abc)defg(hijk

I am not sure a formula solution exists, but I do have a UDF (user defined function) that will work...
Code:
Function CheckParen(ByVal S As String) As String
  Dim X As Long
  For X = 1 To Len(S)
    If Mid(S, X, 1) Like "[!()]" Then Mid(S, X) = " "
  Next
  S = Replace(S, " ", "")
  Do While Len(S) > 1 And S Like "*()*"
    S = Replace(S, "()", "")
  Loop
  If S = ")(" Then
    CheckParen = "Backward"
  ElseIf Len(S) Then
    CheckParen = "Missing " & Choose(InStr("()", S), ")", "(")
  End If
End Function

HOW TO INSTALL UDFs
------------------------------------
If you are new to UDFs, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. You can now use CheckParen just like it was a built-in Excel function. For example,

=CheckParen(A1)

If you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 
Last edited:
Upvote 0
Thanks Rick, you are right, a formula should handle backward matching pairs too.
By the way, when I try the Function in post #9 with „(((ksfsf)gdg” I get „Missing” as a result.
 
Upvote 0

Forum statistics

Threads
1,215,035
Messages
6,122,791
Members
449,095
Latest member
m_smith_solihull

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