Vai al contenuto principale

Come sommare i numeri tra parentesi solo in Excel?

Se c'è un elenco di stringhe di testo e vuoi solo sommare tutti i numeri tra parentesi come mostrato nell'immagine sottostante, come puoi gestirlo rapidamente? In questo articolo, introduco alcuni trucchi per sommare i numeri tra parentesi solo in Excel.


Somma i numeri tra parentesi solo con la formula

Per sommare i numeri solo tra parentesi, è possibile estrarre prima i numeri che sono tra parentesi, quindi sommarli.

1. Seleziona una cella vuota accanto alla cella di cui desideri sommare i suoi numeri tra parentesi, ad esempio B2, inserisci questa formula
=IF(ISERROR(MID(A1,FIND("(",A1)+1,(FIND(")",A1))-(FIND("(",A1)+1))),0,(MID(A1,FIND("(",A1)+1,(FIND(")",A1))-(FIND("(",A1)+1)))+0),
quindi trascina verso il basso la maniglia di riempimento automatico per estrarre i numeri tra parentesi da ciascuna cella. Vedi screenshot:
somma dei documenti tra parentesi 2

Consiglio: nella formula, A1 è la cella da cui si desidera estrarre i numeri tra parentesi.

2. Selezionare una cella in cui posizionare il risultato della somma, immettere = SOMMA (B1: B8)e premere entrare chiave. Vedi screenshot:
somma dei documenti tra parentesi 3

Mancia: nella formula, B1: B8 sono i numeri estratti dall'elenco originale di stringhe di testo e che vuoi riassumere.


Somma i numeri tra parentesi solo con la funzione definita

È inoltre possibile applicare una funzione definita per sommare i numeri tra parentesi.

1. Stampa Alt + F11 tasti per abilitare Microsoft Visual Basic, Applications Edition finestra, fare clic inserire > Modulie incolla il codice sottostante nello script vuoto.

VBA: somma i numeri tra parentesi

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

somma dei documenti tra parentesi 4

2. Salvare il codice e andare a selezionare una cella che inserirà il risultato e inserire questa formula = SumBracket (A1: A8), stampa entrare chiave. Vedi screenshot:
somma dei documenti tra parentesi 5


Somma i numeri tra parentesi solo con Kutools per Excel

In realtà, con Kutools for Excel'S Estrai testo funzione per estrarre i numeri tra parentesi, quindi applicare il Somma i valori assoluti funzione per sommare i numeri.

Kutools for Excel, con oltre 300 funzioni utili, rende il tuo lavoro più facile. 

Dopo l'installazione Kutools per Excel, fai come di seguito :(Scarica gratuitamente Kutools per Excel adesso!)

1. Selezionare le stringhe in cui si desidera estrarre i numeri tra parentesi e fare clic Kutools> Testo > Estrai testo. Vedi screenshot:
somma dei documenti tra parentesi 6

2. Nel Estrai testo dialogo, invio (*) nella Testo casella di testo e fare clic su Aggiungi per aggiungerlo al Estrai elenco. Quindi fare clic Oke per selezionare una cella in cui posizionare i numeri estratti nella finestra di dialogo popping, ad esempio C1. Vedi screenshot:

Nota: Se sono presenti altre regole di estrazione nel file Estrai elenco sezione, deseleziona queste regole di estrazione e controlla solo la nuova regola di estrazione aggiunta di (*).


somma dei documenti tra parentesi 7 freccia scoccata a destra somma dei documenti tra parentesi 8

3. Clic OKe ora vengono estratti i numeri tra parentesi. Per impostazione predefinita, i numeri tra parentesi sono riconosciuti come negativi, è necessario sommare i loro valori assoluti.
somma dei documenti tra parentesi 9

4. Selezionare una cella in cui posizionare il risultato del calcolo, fare clic su Kutools > formula Helper > Math & Trig > Somma i valori assoluti. Vedi screenshot:
somma dei documenti tra parentesi 10

5. Nel formula Helper finestra di dialogo, selezionare l'intervallo che contiene i numeri estratti in Numero casella di testo, C1: C8 in questo caso. Clic Ok, sono stati aggiunti i valori assoluti dei numeri. Vedi screenshot:

somma dei documenti tra parentesi 11 freccia scoccata a destra somma dei documenti tra parentesi 12

Tipo. Se vuoi avere una prova gratuita di Estrai testo ed Somma il valore assolutofunzione s, per favore vai al download gratuito di Kutools per Excel prima, quindi vai ad applicare l'operazione secondo i passaggi precedenti.

I migliori strumenti per la produttività in ufficio

🤖 Assistente AI di Kutools: Rivoluziona l'analisi dei dati basandosi su: Esecuzione intelligente   |  Genera codice  |  Crea formule personalizzate  |  Analizzare i dati e generare grafici  |  Richiama le funzioni di Kutools...
Funzioni popolari: Trova, evidenzia o identifica i duplicati   |  Elimina righe vuote   |  Combina colonne o celle senza perdere dati   |   Round senza formula ...
Super ricerca: VLookup a criteri multipli    VLookup a valori multipli  |   VLookup su più fogli   |   Ricerca fuzzy ....
Elenco a discesa avanzato: Crea rapidamente un elenco a discesa   |  Elenco a discesa dipendente   |  Elenco a discesa a selezione multipla ....
Gestore di colonna: Aggiungi un numero specifico di colonne  |  Sposta colonne  |  Attiva/disattiva lo stato di visibilità delle colonne nascoste  |  Confronta intervalli e colonne ...
Funzionalità in primo piano: Messa a fuoco della griglia   |  Vista di progettazione   |   Grande barra delle formule    Gestore di cartelle di lavoro e fogli   |  Resource Library (Testo automatico)   |  Date picker   |  Combina fogli di lavoro   |  Crittografa/decrittografa le celle    Invia e-mail per elenco   |  Super filtro   |   Filtro speciale (filtro grassetto/corsivo/barrato...) ...
I 15 migliori set di strumenti12 Testo Strumenti (aggiungi testo, Rimuovi personaggi, ...)   |   50+ Grafico Tipi (Diagramma di Gantt, ...)   |   40+ Pratico Formule (Calcola l'età in base al compleanno, ...)   |   19 Inserimento Strumenti (Inserisci il codice QR, Inserisci immagine dal percorso, ...)   |   12 Conversione Strumenti (Numeri in parole, Conversione di valuta, ...)   |   7 Unisci e dividi Strumenti (Combina righe avanzate, Celle divise, ...)   |   ... e altro ancora

Potenzia le tue competenze di Excel con Kutools per Excel e sperimenta l'efficienza come mai prima d'ora. Kutools per Excel offre oltre 300 funzionalità avanzate per aumentare la produttività e risparmiare tempo.  Fai clic qui per ottenere la funzionalità di cui hai più bisogno...

Descrizione


Office Tab porta l'interfaccia a schede in Office e semplifica notevolmente il tuo lavoro

  • Abilita la modifica e la lettura a schede in Word, Excel, PowerPoint, Publisher, Access, Visio e Project.
  • Apri e crea più documenti in nuove schede della stessa finestra, piuttosto che in nuove finestre.
  • Aumenta la produttività del 50% e riduce ogni giorno centinaia di clic del mouse!
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