0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

EXCEL VBAではSQLの正規表現に%を使う

Last updated at Posted at 2021-09-05

EXCELVBAでSQLの正規表現を使うときにハマってしまったことをメモ。

EXCELVBAでは正規表現に✳︎ではなく%を使わなきゃいけないみたい。

誤
SELECT 列名 FROM テーブル名 WHERE 列名 LIKE '% ✳︎検索文字列✳︎'

正
SELECT 列名 FROM テーブル名 WHERE 列名 LIKE '%検索文字列%'

まずAccessのクエリでSQLを作り、データをちゃんとひっぱってこれることを確認してから、ExcelVBAにそのSQLをコピペしてたんですが、1件もヒットせず。特にエラーが出るわけでもないので、原因がわかるまで1〜2時間費やしてしまった( ; ; )

初歩的なミスでした。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?