特定の文字に囲まれた文字列を取得する方法

この関数はEXCELにはありません。その場合にはSEARCH関数を使いましょう。

ACCESSでは文字列関数である Instr と Mid 関数を使用し実現できます。

Instr関数は任意の文字列中にある指定した文字の左端からの位置を返します。

この関数を利用して、まず任意の文字列を囲んでいる左側にある特定の文字の位置を求めます。
① Instr(“任意の文字列”,”左側の特定文字”)

次にその位置から数えた任意の文字列の右側にある特定の文字の位置を求めます。
② Instr(Instr(“任意の文字列”,”左側の特定文字”),”任意の文字列”,”右側の特定文字”)

求められた①の位置から②の位置-1までの文字列が求めたい文字列の始まりと終わりの位置になります。
Mid(”任意の文字列”,Instr(“任意の文字列”,”左側の特定文字”),Instr(Instr(“任意の文字列”,”左側の特定文字”),”任意の文字列”,”右側の特定文字”)-1)

 

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny

タイトルとURLをコピーしました