메인 컨텐츠로 가기

Excel에서만 대괄호로 숫자를 합산하는 방법은 무엇입니까?

텍스트 문자열 목록이 있고 아래 스크린 샷과 같이 괄호 안에 모든 숫자를 더하고 싶다면 어떻게 빨리 처리 할 수 ​​있습니까? 이 기사에서는 Excel에서만 괄호 안에 숫자를 합산하는 몇 가지 트릭을 소개합니다.


수식으로 만 괄호 안의 숫자 합계

괄호 안의 숫자 만 합산하려면 먼저 괄호 안에있는 숫자를 추출한 다음 더하면됩니다.

1. 괄호 안에 숫자를 더할 셀 옆에있는 빈 셀 (예 : B2)을 선택하고 다음 수식을 입력합니다.
=IF(ISERROR(MID(A1,FIND("(",A1)+1,(FIND(")",A1))-(FIND("(",A1)+1))),0,(MID(A1,FIND("(",A1)+1,(FIND(")",A1))-(FIND("(",A1)+1)))+0),
그런 다음 자동 채우기 핸들을 아래로 드래그하여 각 셀에서 괄호 안에있는 숫자를 추출합니다. 스크린 샷보기 :
괄호 안의 문서 합계 번호 2

: 수식에서 A1은 괄호 안의 숫자를 추출하려는 셀입니다.

2. 합산 결과를 배치 할 셀을 선택하고 = SUM (B1 : B8), 그리고 언론 엔터 버튼 키. 스크린 샷보기 :
괄호 안의 문서 합계 번호 3

팁 : 공식에서 B1 : B8은 텍스트 문자열의 원래 목록에서 추출하고 합산하려는 숫자입니다.


정의 된 함수로만 괄호 안의 합계 숫자

정의 된 함수를 적용하여 괄호 안의 숫자를 합산 할 수도 있습니다.

1. 프레스 Alt + F11 활성화 할 키 응용 프로그램 용 Microsoft Visual Basic 창을 클릭합니다 끼워 넣다 > 모듈을 클릭하고 코드 아래 빈 스크립트에 붙여 넣습니다.

VBA : 괄호 안의 합계 숫자

Function SumBracket(Target As Range) As Double
'UpdatebyExtendoffice20160901
Dim xCell As Range
Dim xObjs As Object, xObj As Object
Dim xSum As Double
Set xObjs = CreateObject("VBScript.RegExp")
xSum = 0
With xObjs
    .Global = True
    .Pattern = "\((\d+(\.\d+)?)\)"

    For Each xCell In Target
      If xCell.Value <> "" Then
        For Each xObj In xObjs.Execute(xCell.Value)
            xSum = xSum + xObj.submatches(0)
        Next
      End If
    Next
End With
SumBracket = xSum
End Function

괄호 안의 문서 합계 번호 4

2. 코드를 저장하고 결과를 배치 할 셀을 선택하고이 수식을 입력합니다. = SumBracket (A1 : A8), 언론 엔터 버튼 키. 스크린 샷보기 :
괄호 안의 문서 합계 번호 5


Excel 용 Kutools에서만 괄호 안의 합계 숫자

사실, Excel 용 Kutools텍스트 추출 함수를 사용하여 괄호 안의 숫자를 추출한 다음 절대 값 합계 숫자를 합산하는 함수.

Excel 용 Kutools, 이상과 300 편리한 기능으로 작업이 더 쉬워집니다. 

설치 후 Excel 용 Kutools는 다음과 같이하십시오 :(지금 Excel 용 Kutools를 무료로 다운로드하십시오!)

1. 괄호 안에 숫자를 추출 할 문자열을 선택하고 쿠툴s> 본문 > 텍스트 추출. 스크린 샷보기 :
괄호 안의 문서 합계 번호 6

2. 에서 텍스트 추출 대화 상자, 입력 (*)본문 텍스트 상자를 클릭하고 추가 그것을 추가하려면 목록 추출. 그런 다음 Ok, 그리고 추출 된 숫자를 팝업 대화 상자에 배치 할 셀을 선택하려면 예를 들어 C1입니다. 스크린 샷보기 :

참고 : 다른 추출 규칙이있는 경우 목록 추출 섹션에서이 추출 규칙의 선택을 취소하고 새로 추가 된 추출 규칙 만 확인하십시오. (*).


괄호 안의 문서 합계 번호 7 샷 화살표 오른쪽 괄호 안의 문서 합계 번호 8

3. 클릭 OK, 이제 괄호 안의 숫자가 추출됩니다. 기본적으로 괄호 안의 숫자는 음수로 인식되며 절대 값을 합산해야합니다.
괄호 안의 문서 합계 번호 9

4. 계산 결과를 배치 할 셀을 선택하고 쿠툴 > 수식 도우미 > 수학 및 삼각 > 절대 값 합계. 스크린 샷보기 :
괄호 안의 문서 합계 번호 10

5. 에서 수식 도우미 대화 상자에서 추출 된 숫자를 포함하는 범위를 선택하십시오. 번호 텍스트 상자,이 경우 C1 : C8. 딸깍 하는 소리 Ok, 숫자의 절대 값이 추가되었습니다. 스크린 샷보기 :

괄호 안의 문서 합계 번호 11 샷 화살표 오른쪽 괄호 안의 문서 합계 번호 12

팁. 무료 평가판을 원하시면 텍스트 추출절대 값 합계s 기능, Excel 용 Kutools를 무료로 다운로드하십시오. 먼저 위의 단계에 따라 작업을 적용하십시오.

최고의 사무 생산성 도구

🤖 Kutools AI 보좌관: 다음을 기반으로 데이터 분석을 혁신합니다. 지능형 실행   |  코드 생성  |  사용자 정의 수식 만들기  |  데이터 분석 및 차트 생성  |  Kutools 기능 호출...
인기 기능: 중복 항목 찾기, 강조 표시 또는 식별   |  빈 행 삭제   |  데이터 손실 없이 열이나 셀 결합   |   수식없이 반올림 ...
슈퍼 조회: 다중 기준 VLookup    다중 값 VLookup  |   여러 시트에 걸친 VLookup   |   퍼지 조회 ....
고급 드롭다운 목록: 드롭다운 목록을 빠르게 생성   |  종속 드롭다운 목록   |  다중 선택 드롭 다운 목록 ....
열 관리자: 특정 개수의 열 추가  |  열 이동  |  Toggle 숨겨진 열의 가시성 상태  |  범위 및 열 비교 ...
특색 지어진 특징: 그리드 포커스   |  디자인보기   |   큰 수식 바    통합 문서 및 시트 관리자   |  리소스 라이브러리 (자동 텍스트)   |  날짜 선택기   |  워크 시트 결합   |  셀 암호화/해독    목록으로 이메일 보내기   |  슈퍼 필터   |   특수 필터 (굵게/기울임꼴/취소선 필터링...) ...
상위 15개 도구 세트12 본문 도구 (텍스트 추가, 문자 제거,...)   |   50+ 거래차트 유형 (Gantt 차트,...)   |   40+ 실용 방식 (생일을 기준으로 나이 계산,...)   |   19 삽입 도구 (QR 코드 삽입, 경로에서 그림 삽입,...)   |   12 매출 상승 도구 (숫자를 단어로, 환율,...)   |   7 병합 및 분할 도구 (고급 결합 행, 셀 분할,...)   |   ... 그리고 더

Excel용 Kutools로 Excel 기술을 강화하고 이전과는 전혀 다른 효율성을 경험해 보세요. Excel용 Kutools는 생산성을 높이고 시간을 절약하기 위해 300개 이상의 고급 기능을 제공합니다.  가장 필요한 기능을 얻으려면 여기를 클릭하십시오...

상품 설명


Office Tab은 Office에 탭 인터페이스를 제공하여 작업을 훨씬 쉽게 만듭니다.

  • Word, Excel, PowerPoint에서 탭 편집 및 읽기 사용, Publisher, Access, Visio 및 Project.
  • 새 창이 아닌 동일한 창의 새 탭에서 여러 문서를 열고 만듭니다.
  • 생산성을 50% 높이고 매일 수백 번의 마우스 클릭을 줄입니다!
Comments (15)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hello Sunny,

I have a question as well. I have an excel sheet with numbers and some of them are in brackets. I want to add the values of the numbers in a row. Basically:
50 (50*) 100 150 = 350
How can I add (=sum) of all of them, including the one in brackets? I'ld appreciate your advise.
Best, Anna
This comment was minimized by the moderator on the site
Vielen Dank Sonnig,

jetzt ich sehe wo war das Problem. Sie schreiben im VBA und Zelle "." statt wie bei mir "," Ich habe im VBA diese Zeile:
.Pattern = "\((\d+(\.\d+)?)\)"
in diese:
.Pattern = "\((\d+(\,\d+)?)\)"
geändert und dann funktioniert alles perfekt.

Noch mall vielen, vielen Dank.
Schöne Grüße

Wojtek
This comment was minimized by the moderator on the site
...ich meinte addieren Dezimalbruche 🙂
This comment was minimized by the moderator on the site
Hi, Wojtek, if you just want to sum the decimal numbers only, try this code:
Function SumBracket(Target As Range) As Double
'UpdatebyExtendoffice20221209
Dim xCell As Range
Dim xObjs As Object, xObj As Object
Dim xSum As Double
Dim xNum As Integer
On Error Resume Next
Application.Volatile
Set xObjs = CreateObject("VBScript.RegExp")
xSum = 0
With xObjs
    .Global = True
    .Pattern = "\((\d+(\.\d+)?)\)"

    For Each xCell In Target
      If xCell.Value <> "" Then
        For Each xObj In xObjs.Execute(xCell.Value)
            xSum = xSum + Val(xObj.submatches(0)) - Int(Val(xObj.submatches(0)))
        Next
      End If
    Next
End With
SumBracket = xSum
End Function
This comment was minimized by the moderator on the site
Hallo Sonnig,
vielen Dank für die schnelle Antwort 😀. Um die Ganze klar zu machen gebe ich ein Beispiel meiner Aufgabe:

a(5), b(2,5), c(0,25) = 7,75

wie gesagt, mit:

a(5), b(2), c(21) im eine Zelle funktioniert die erste Makro super.

Vielen Dank und schöne Grüße
Wojtek
This comment was minimized by the moderator on the site
Sorry, Wojtek, I do undestand Geman, I just translate your question by Google so that I do not get your question clearly. Could you give me more description, for example, the data structure, are they in a cell or in different cell, in a column or in a row, what result you want.
This comment was minimized by the moderator on the site
Hallo Sonnig,

noch mal vielen Dank für die Mühe.

Geht um Summe alle Zahlen die in der Klammer stehen...
Erste Zelle: 458/1(2,5), 458/2(11), 458/3(0,75)
Zweite Zelle: Summe von 2,5 und 11 und 0,75
alles was in der Klammer steht in der erste Zelle sollte summiert sein. das Ergebnis soll in der Zweite Zelle erscheinen.

Vielen Dank und schöne Grüße
Wojtek
This comment was minimized by the moderator on the site
Hallo,
danke, Makro funktioniert super, aber leider nur mit Ganze Zahl, nicht mit Bruchzahl. Wäre das möglich zu ändern?
This comment was minimized by the moderator on the site
I'm sorry, I meant adding the numbers outside the bracket.
This comment was minimized by the moderator on the site
Hi, Adduar, I do not find a formula to solve your problem, maybe you only can use the Extract Text tool of Kutools for Excel to extract the numbers first, and then sum them, the conditions are *( and )*.
This comment was minimized by the moderator on the site
How to add numbers within the bracket?
This comment was minimized by the moderator on the site
Hi, How do I modify the pattern to sum everything between F-( and )


Example of my data is: F-(10) F-(12) E-(8)


the sum would be 22


thanks
This comment was minimized by the moderator on the site
Hi, Andy, please try this code:
Function SumBracket(Target As Range) As Double
'UpdatebyExtendoffice20160901
Dim xCell As Range
Dim xObjs As Object, xObj As Object
Dim xSum As Double
Set xObjs = CreateObject("VBScript.RegExp")
xSum = 0
With xObjs
.Global = True
.Pattern = "\-\((\d+(\.\d+)?)\)"

For Each xCell In Target
If xCell.Value <> "" Then
For Each xObj In xObjs.Execute(xCell.Value)
xSum = xSum + xObj.submatches(0)
Next
End If
Next
End With
SumBracket = xSum
End Function
This comment was minimized by the moderator on the site
Hello, is there a Google App Script version of the VBA script. I would like to use it in Google Sheets.
Thanks. :D
This comment was minimized by the moderator on the site
Sorry I do not know
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations