Skip to Content
エクセル・クックブック
book

エクセル・クックブック

by Dawn Griffiths
March 2025
Beginner to intermediate
592 pages
7h 52m
Japanese
O'Reilly Media, Inc.
Content preview from エクセル・クックブック

第5章. テキスト操作

この作品はAIを使って翻訳されている。ご意見、ご感想をお待ちしている:translation-feedback@oreilly.com

エクセルはワープロではないが、多くの場面で文字列を操作し、特定のモデルに合うようにデータを変換する必要がある。

この章では、テキストの結合、数値コードの抽出、余分なスペースや文字の削除、通貨、数値、日付/時刻値へのテキスト形式の適用など、一般的なテキスト操作の実行に数式を使用する方法を紹介する。

ExcelのPower Queryツールを使って、この章の演算子の多くを実行することもできる。詳しくは第15章を参照のこと。

5.1 テキストの連結

問題

2つ以上の文字列があり、それらを結合したい。

解決策

セルA1にJohn、B1にDoeという文字列があり、2つの文字列を結合したいとする。

ひとつのメソッドは& 。これは2つの文字列を連結する演算子である。 例えばセルC1に =A1&B1をセルC1に入力すると、B1のテキストがA1のテキストの最後に追加され、JohnDoeというテキストが返される。2つの文字列の間にスペースを挿入し、代わりにJohn Doeを返したい場合は、次の数式を入力する。 =A1&" "&B1これは、B1のテキストを追加する前に、A1のテキストの最後にスペースを追加する。

チップ

スペースなどの静的な テキストは二重引用符で囲み、セル参照などExcelに評価させたいものは省略しなければならない。例えば、=A1&B1 の数式はセルA1とB1の内容を結合し、="A1"&"B1" の数式はテキストA1B1を返す。

別の方法としては、CONCAT 関数を使う方法がある。 一般的には、次のように使う。 =CONCAT(text1, text2, …​)ここで text1, text2などは連結したいテキスト値である。例えば =CONCAT(A1, " ", B1)と入力すると、=A1&" "&B1 という式と等価性を持ち、John Doeを返す。

Excel 2019以降を使用している場合、、区切り文字を指定し、空の呼び出しは無視できるTEXTJOIN 関数を使用できる。一般化すると、次のようになる。 =TEXTJOIN(delimiter, ignore_empty, text_values)ここで delimiterは各テキスト値間の区切り文字である、 ignore_emptyは空のセルを無視するかどうかを指定し text_valuesはセルやセル範囲など、結合したいテキストを指す。例えば、スペースで区切られたセルA1とB1のテキストを結合するには、次のように入力する。 =TEXTJOIN(" ", TRUE, A1, B1)または =TEXTJOIN(" ", TRUE, A1:B1)と入力する。同様に、セルA1:A5のテキストをカンマとスペースで区切って結合するには、次のようにタイプする。 =TEXTJOIN(", ", TRUE, A1:A5).

Screenshot of using the TEXTJOIN function
図5-1. TEXTJOIN 、テキストを連結する。

ディスカッション

このレシピでは、& 演算子やCONCATTEXTJOIN 関数を使ってテキストを結合する便利な方法を提供する。また、レシピ5.15を使って ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

はじめての知識グラフ構築ガイド

はじめての知識グラフ構築ガイド

Jesus Barrasa, Jim Webber
MySQL管理ハンズオン

MySQL管理ハンズオン

Arunjith Aravindan, Jeyaram Ayyalusamy

Publisher Resources

ISBN: 9798341626973