Front-End & Daily

How to convert strings in '0,000 yen' format to numbers in Excel or Spreadsheets

How to convert strings in '0,000 yen' format to numbers in Excel or Spreadsheets

In Excel or Spreadsheets, you cannot calculate totals when values are in the following format:

How to convert strings in '0,000 yen' format to numbers in Excel or Spreadsheets

This is because values like "12,000 yen" are interpreted as strings, not numbers.

It's like saying "Tokyo + Hokkaido = ?".

Therefore, you need to convert "12,000 yen" and similar values into numbers using functions.

I will explain using a Spreadsheet example.

There are slight differences between Excel and Spreadsheets, which I will explain as we go along.

Table of Contents

Conclusion

For Spreadsheets:

Combine the replacement function "REGEXREPLACE()" and

the number conversion function "VALUE()" as follows:

=VALUE(REGEXREPLACE(B2,"[^0-9]",""))

Please change the "B2" part as appropriate.

This uses regular expressions to remove non-half-width numbers and then converts the result to a number.

As a result, "12,000 yen" has changed to the numerical value "12000".

REGEXREPLACE function and VALUE function

The total could also be calculated.

REGEXREPLACE function and VALUE function

For Excel

Excel does not have the "REGEXREPLACE()" function, so
use the "SUBSTITUTE()" function to remove "yen" and "," and then convert to a number with VALUE().

=VALUE(SUBSTITUTE(SUBSTITUTE(B2,"円",""),",",""))

Please change the "B2" part as appropriate.

Convert string to number in Excel

For full-width numbers

Consider a case like this:

Convert full-width numbers to numerical values

Process by converting full-width characters to half-width using the "ASC()" function first.

=VALUE(REGEXREPLACE(ASC(B2),"[^0-9]",""))

Please change the "B2" part as appropriate.

It converted to a number, and the total could also be calculated.

For Excel

The previous function works for both full-width and half-width numbers.

=VALUE(SUBSTITUTE(SUBSTITUTE(B2,"円",""),",",""))

Comments

If you found a different behavior in your environment, please feel free to leave a comment.

After reviewing the content, we will publish it, omitting personal information.

Enter your name and email address

Please enter if you would like a reply via email.

Personal information provided will not be disclosed. It will only be used for replies.

It will be sent directly. Please confirm and click "Send".

If this was helpful, we appreciate your support!
Your support will be used for childcare.

Send support via OFUSE


Or support us by buying something from the buttons below
(You don't have to buy the linked product.)

Amazon

Rakuten Ichiba

Yahoo! Shopping

PR

As an Amazon Associate, "Ken" earns income from eligible sales.

Share

Share on Twitter Share on Facebook Share on LINE Share on Hatena Bookmark