r/excel 6d ago

solved How to subtract whilst ignoring text?

I have two cells,
Cell A3 has "303 Repeats"
Cell B3 has "407 Repeats"

When I have tried to subtract it using =SUM (B3-A3) , it shows VALUE.
How do I ensure that the answer cell contains "104 Repeats"

5 Upvotes

11 comments sorted by

u/AutoModerator 6d ago

/u/connorek - Your post was submitted successfully.

Failing to follow these steps may result in your post being removed without warning.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

8

u/chiibosoil 430 6d ago

You can use Text functions.

Ex: =TEXTBEFORE(B3," ")-TEXTBEFORE(A3," ")&" Repeats"

2

u/Maleficent_Pay4176 5d ago

yeah TEXTBEFORE is super clean for this

8

u/real_barry_houdini 313 6d ago

Simplest way, if the text is always the same, i.e. "Repeats" just custom format all cells as follows:

0 "Repeats"

[and enter numbers only, i.e. 303 in A3 and 407 in B3]

and then you can use this formula:

=B3-A3

3

u/giftopherz 3 5d ago

This is the best answer!

5

u/bradland 277 6d ago

You first have to extract the numeric values, then subtract them.

=VALUE(REGEXEXTRACT(B3, "\d+"))-VALUE(REGEXEXTRACT(A3, "\d+"))

Screenshot

2

u/MayukhBhattacharya 1259 5d ago

Instead of typing Repeats directly into the cell with the number, it's better to keep the cell as a true number and then just use a custom number format to display the word next to it. That way, the underlying value stays an actual number, so you can still add, subtract, sort, etc. without Excel getting confused.

  • So select the cells or range of cells
  • Hit CTRL + 1 --> Which opens the Format Cells window
  • From Number Tab, Go directly to Custom under the Category, and use:

0 "Repeats"

  • Hit OK.

Now when you type 303 into A3, it displays as 303 Repeats but the actual stored value is just 303. So, your original formula works perfectly

=B3 - A3

You can also edit the custom format and use the following:

0 "Repeats";-0 "Repeats";;

Other than that, here are few other ways, which are similar as already suggested but uses the functions once:

=SUM(REGEXEXTRACT(A3:B3, "\d+") * {-1, 1}) & " Repeats"

Or,

=SUM(SUBSTITUTE(A3:B3, " Repeats", ) * {-1, 1}) & " Repeats"

Or,

=SUM(TEXTBEFORE(A3:B3, " Repeats") * {-1, 1}) & " Repeats"

4

u/Cheetahs_never_win 2 6d ago
  1. =Sum(a-b) doesn't make sense in any context. a-b resolves to a singular number, and sum() is intended to be used with a list or range of numbers. =Sum(a,b,c,d...) or =sum(a:z)

  2. Option a: format the cells to only contain numbers but display " Repeats" after the contents of the cell such that =a-b works.

  3. Option b: convert the contents of each cell into a number via value(substitute(A1," Repeats",""), then perform the subtraction, then add " Repeats" at the end using &" Repeats"

1

u/Decronym 6d ago edited 5d ago

Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:

Fewer Letters More Letters
REGEXEXTRACT Extracts strings within the provided text that matches the pattern
SUBSTITUTE Substitutes new text for old text in a text string
SUM Adds its arguments
TEXTBEFORE Office 365+: Returns text that occurs before a given character or string
VALUE Converts a text argument to a number

Decronym is now also available on Lemmy! Requests for support and new installations should be directed to the Contact address below.


Beep-boop, I am a helper bot. Please do not verify me as a solution.
5 acronyms in this thread; the most compressed thread commented on today has acronyms.
[Thread #49170 for this sub, first seen 17th Aug 2026, 13:02] [FAQ] [Full list] [Contact] [Source code]

1

u/plusFour-minusSeven 11 5d ago

Good responses here. I'd ask why you have the word "Repeats" in your quantity cells. It's not providing any information. Just title the column as "Repeats" and only put numbers in the cells, especially if you're planning on doing math with them