Excel で特定の文字列を抽出する方法
抽出したい文字数が決まっている場合
特定の 2 文字または他の文字番号を抽出する場合は、取得する位置に応じて 3 つの関数を使用します。
文字列の先頭から抽出する場合のLEAF関数
LEFT 関数を使用して、左から文字列を取得します。
この関数は “=LEFT(文字列,[文字数]) をクリックし、文字列の先頭から指定した文字数を返します。[文字数]省略してもかまいませんが、その場合は文字列の最初の文字が出力されます。
B2 セルに入力され、C2 セルに表示される文字列 “ABCDEFG" から最初の 2 文字が取得された場合は、C2 セルに「=LEFT(B2,2)」と入力します。
文字列の先頭から 2 文字の “AB" が C2 セルに抽出されました。
文字列の末尾から抽出するときのRIGHT関数
右側から文字列を取得する場合は、RIGHT 関数を使用します。
この関数は “=RIGHT(文字列、[文字数]) をクリックし、文字列の末尾から指定した文字数を返します。[文字数]省略することができ、その場合は文字列の末尾から 1 文字が出力されます。
B2セルに入力した文字列「ABCDEFG」の末尾から2文字を抽出してC2セルに表示したい場合は、C2セルに「=RIGHT(B2,2)」と入力します。
文字列の末尾から “FG" の 2 文字が C2 セルに抽出されました。
文字列の途中から抽出するときの MID 関数
文字列の途中から文字列を取得する場合は、MID 関数を使用します。
この関数は “=MID (文字列、開始位置、文字数)" で構成され、文字列の指定された位置から指定された文字数を返します。
B2 セルに入力した文字列 “ABCDEFG" の先頭から 3 番目以降の文字を抽出し、C2 セルに表示する場合は、C2 セルに =MID (B2, 3, 2) と入力します。
文字列 “CD" の 3 番目から 2 番目の文字は、C2 セルに抽出されました。
このページを閲覧している方におすすめの商品
抽出する文字数が異なる場合
上記では、抽出する文字数を固定していましたが、条件に合致する文字列を抽出する場合、必ずしも文字数が固定されているとは限りません。今回は、ダミーメールアドレスを使って抽出した文字数が異なる場合を例に説明します。
抽出する文字列に共通する文字 (電子メール アドレス、電話番号、住所など) がある場合は、FIND 関数を使用します。一般的な文字は、電子メール アドレスの場合は “@(アットマーク)"、電話番号の場合は -(ハイフン) です。まず、FIND関数の使い方を見てみましょう。
上記のメールアドレスデータを例にFIND機能の使い方を説明しましょう。
FIND 関数は “=FIND (検索文字列、ターゲット、[開始位置]) を使用して、他の文字列で指定した文字列を検索するには、文字列が左端から出現する最初の位置をカウントし、数値を返します。
[開始位置]省略することができ、その場合、それは1であるとみなされる。
上記の例では、B2セル文字列の「@」の位置が出力されています。C2 セルに「=FIND(“@", B2)」と入力します。
@の左端からの位置である「5」をC2セルに出力した。
オートフィルを使用して、C2 セルの右下をプルダウンして、他の行を計算します。各行の@位置を出力することができました。
上記のLEFT関数、RIGHT関数、MID関数、FIND関数を組み合わせて文字数が違っても抽出する方法を説明しましょう。
左からテキストを抽出して検索する
上の図の例は、文字列の先頭から「@」まで文字列を抽出したい場合です。この場合、LEFT関数 “=LEFT(B2,?)"だけでは文字数を計算することができません。
このような場合、検索文字「@」の位置からLEFT関数で指定した文字数に1を引くことで文字数を計算できます。
C2 セルに「=LEFT(B2,FIND(“@", B2)-1).
左端から@までの文字列 “hoge"がC2セルに出力されました。
オートフィルを使用してC2セルの右下をプルダウンすることで、他の行から文字列を抽出することができました。
右から検索文字までのテキストを抽出する
上の図の例は、文字列の末尾から「@」まで文字列を抽出したい場合です。この場合、RIGHT関数 “=RIGHT(B2,?)"だけで文字数を計算することはできません。
このような場合は、すべての文字から @ に位置を減算することで、RIGHT 関数で指定された文字数を計算できます。
合計文字数を調べるには、文字列内の文字数を返す関数である LEN 関数を使用します。find 関数は、@ までの位置を計算し、すべての文字から減算して @ の後の文字数を計算します。
C2 セルに「=RIGHT(B2,LEN(B2)-FIND (“@", B2)」と入力します。
右端から@までの文字列 “example.com" が C2 セルに出力されました。
オートフィルを使用して、C2セルの右下をプルダウンすることで、他の行の@以降の文字列を抽出することができました。
特定の範囲の文字列を抽出する
上の図の例は、文字列の “@" 以降を示しています。com」までの文字列を抽出したい場合です。この場合、文字数はMID関数"=MID(B2,?,?)だけでは計算できません。」。
このような場合は、開始位置と文字数をFIND関数に置き換えることで計算できます。
開始位置は FIND 関数によって取得され、1 を加算します。文字数は FIND 関数の “"." で、1 を減算します。また、位置を@に減算することで文字数を計算できます。
セル C2 に、=MID(B2,FIND(@", B2)+1, FIND(“.,B2)-1-FIND(“@", B2)" と入力します。
C2セルの “@"以降、 “com"までの文字列 “example"が印刷されました。
オートフィルを使用してC2セルの右下をプルダウンすることで、他の行から文字列を抽出することができました。
Excel 文字列に関する情報の概要
Excelで文字列を組み合わせる方法( “&"または関数を持つ3つの方法)
Excel で文字列を分割するさまざまな方法
Excelセルの余分なスペースを削除する方法
Excel が同じ文字を処理する方法
Excel で指定された文字列が関数に含まれているかどうかを判断する方法
Excel で空白セルを一括削除する方法
ディスカッション
コメント一覧
At the beginning, I was still puzzled. Since I read your article, I have been very impressed. It has provided a lot of innovative ideas for my thesis related to gate.io. Thank u. But I still have some doubts, can you help me? Thanks.
I really enjoy the blog. Will read on…
Really appreciate you sharing this post. Cool.
I think this is a real great post.Thanks Again. Great.
Really informative blog.Thanks Again. Awesome.
Hey, thanks for the article post.Really thank you! Will read on…
I really enjoy the post.Much thanks again.
Say, you got a nice blog post.Thanks Again. Awesome.
Thanks so much for the article.Really looking forward to read more. Much obliged.
Im grateful for the article post. Want more.
Major thankies for the blog post.Really looking forward to read more. Really Cool.
Very neat post.Really thank you! Fantastic.
Thanks for the blog post.Really looking forward to read more. Fantastic.
Looking forward to reading more. Great blog. Cool.
I cannot thank you enough for the article post.Much thanks again. Really Cool.
Really appreciate you sharing this article post.Much thanks again. Cool.
Major thankies for the blog. Fantastic.
Thank you ever so for you blog.Much thanks again. Really Great.
Really informative blog article.Really looking forward to read more. Will read on…
Great post.Really thank you! Really Great.
Thanks again for the blog.Thanks Again. Really Great.
Wow, great blog.Really looking forward to read more. Awesome.
I really like and appreciate your article post. Keep writing.
A round of applause for your blog post.Much thanks again. Awesome.
Awesome blog article. Great.
A big thank you for your article. Will read on…
Great, thanks for sharing this article post.Really thank you! Really Cool.
I think this is a real great blog article.Really looking forward to read more. Much obliged.
Thanks again for the blog article.
I cannot thank you enough for the article post.Thanks Again. Cool.
Muchos Gracias for your post.Really thank you! Keep writing.
A round of applause for your blog post.Much thanks again. Fantastic.
Thanks for the blog post.Really thank you! Really Great.
Im grateful for the post.Really thank you! Really Cool.
Thanks again for the blog post. Keep writing.
Great blog post. Awesome.
Major thanks for the post. Really Cool.
Really enjoyed this blog.Really looking forward to read more. Really Great.
I cannot thank you enough for the post. Awesome.
Really informative blog article. Really Great.
Very good article post. Keep writing.
I really like and appreciate your article.Really looking forward to read more. Want more.
Thanks so much for the blog article. Cool.
Thanks for the blog.Really looking forward to read more. Really Cool.
Great blog post.Really looking forward to read more.
Thanks a lot for the post.Thanks Again. Really Cool.
wow, awesome blog article.Thanks Again. Keep writing.
Thanks for sharing, this is a fantastic article. Really Great.
There’s noticeably a bundle to find out about this. I assume you made sure nice points in options also.
I am so grateful for your blog article.Thanks Again. Awesome.
Having read this I believed it was really informative. I appreciate you finding the time and effort to put Ceme Fighter this informative article together. I once again find myself personally spending a lot of time both reading and leaving comments
Major thanks for the article.Much thanks again. Really Great.
Im grateful for the article.Really looking forward to read more. Great.
Thank you for your article post.Much thanks again. Want more.
Im grateful for the post.Really looking forward to read more. Really Cool.
Major thanks for the blog article.Thanks Again. Awesome.
Hey, thanks for the blog.Much thanks again.
I think this is a real great article.Thanks Again. Really Great.
Скоростроительные здания: бизнес-польза в каждой составляющей!
В сегодняшнем обществе, где моменты – финансы, здания с высокой скоростью строительства стали настоящим выходом для коммерческой деятельности. Эти современные объекты комбинируют в себе высокую прочность, финансовую экономию и ускоренную установку, что дает им возможность лучшим выбором для различных бизнес-проектов.
[url=https://bystrovozvodimye-zdanija-moskva.ru/]Строительство быстровозводимых зданий под ключ цена[/url]
1. Быстрота монтажа: Часы – ключевой момент в коммерции, и скоро возводимые строения дают возможность значительно сократить время строительства. Это особенно ценно в ситуациях, когда срочно нужно начать бизнес и получать доход.
2. Экономия средств: За счет улучшения процессов изготовления элементов и сборки на объекте, цена скоростроительных зданий часто уменьшается, по сравнению с обычными строительными задачами. Это дает возможность сэкономить деньги и достичь более высокой инвестиционной доходности.
Подробнее на [url=https://bystrovozvodimye-zdanija-moskva.ru/]www.scholding.ru[/url]
В заключение, скоро возводимые строения – это оптимальное решение для бизнес-проектов. Они сочетают в себе быстрое строительство, финансовую эффективность и твердость, что делает их первоклассным вариантом для предпринимателей, стремящихся оперативно начать предпринимательскую деятельность и получать доход. Не упустите возможность получить выгоду в виде сэкономленного времени и денег, наилучшие объекты быстрого возвода для вашего следующего начинания!
Enjoyed every bit of your article.Really thank you! Cool.
I really liked your blog article.Much thanks again. Really Cool.
Hey, thanks for the article post.Much thanks again. Fantastic.
Hello There. I found your blog using msn. This is a very well written article.I’ll make sure to bookmark it and return to read more of your useful info.Thanks for the post. I will certainly comeback.
express scripts com pharmacies community rx pharmacy warren mi
I think this is a real great post. Great.
Thanks for the article.Really looking forward to read more. Want more.
I think this is a real great post.Really thank you!
I value the post.Much thanks again. Fantastic.
I appreciate you sharing this blog.Really thank you! Fantastic.
Im grateful for the article post. Awesome.
Im thankful for the blog article.Really looking forward to read more. Keep writing.
Fantastic blog post.Really thank you! Want more.
Major thankies for the blog article.Really looking forward to read more. Keep writing.
I appreciate you sharing this blog article.Much thanks again. Will read on…
Muchos Gracias for your post.Much thanks again. Cool.
Thank you ever so for you blog. Really Great.
Very informative blog post.Thanks Again. Keep writing.
Looking forward to reading more. Great blog post. Really Cool.
Awesome article post.Really looking forward to read more. Really Great.
I really liked your article post.Much thanks again. Really Great.
Hey, thanks for the article post.Really looking forward to read more. Really Cool.
I appreciate you sharing this blog.Thanks Again. Really Great.
Закажите SEO продвижение сайта https://seo116.ru/ в Яндекс и Google под ключ в Москве и по всей России от экспертов. Увеличение трафика, рост клиентов, онлайн поддержка. Комплексное продвижение сайтов с гарантией!
Всё о радиаторах отопления https://heat-komfort.ru/ – выбор радиатора, монтаж, обслуживание.
вован казино
Thank you ever so for you blog article.Really thank you! Really Great.
A round of applause for your article.Much thanks again. Really Great.
I loved your blog.Thanks Again. Really Great.
Hey, thanks for the blog post. Really Cool.