1
0

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.

備忘録 - VBA関数とワークシート関数 【VBA】

Posted at

VBA関数とワークシート関数

VBA関数:VBAに組み込みの関数。「VBA.」でリストを見ることができる。
ワークシート関数:エクセルのワークシートで用いる関数。VBAでも使用可。「Excel.」又は「Application.」でリストを見ることができる。

同じ意味の関数がある場合

VBA関数が存在するものに関しては、ワークシート関数はVBAでは基本的に使用できない。

例えば、本日の日付を表すワークシート関数のTODAY関数は以下のようにエクセルで用いる
  image.png
  image.png

一方で、VBA関数に同じ意味のDATE関数があるので、VBEで以下のように、使おうとすると

 Range("A1") = Today()

以下のようなエラーがでる
  Error Message.png

Date関数を使うと、本日の日付を表示できる

 Range("A1") = Date

【例外】同じ意味のワークシート関数が使える場合

'VBA関数を使って単語の頭文字を大文字にする
  Range("A1").Value = StrConv(.Range("B1").Value, vbProperCase)
'ワークシート関数を使って単語の頭文字を大文字にする        
  Range("A1").Value = Excel.Application.WorksheetFunction.Proper(.Range("B1").Value)
1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?