「Excel/VBA/基本」の版間の差分
提供: 初心者エンジニアの簡易メモ
(ページの作成:「==基本== マクロのmodule1に以下を記述 <pre> public Function Test dim a as integer dim b as integer dim c as string c = "hello" a = 2 b = 1 Test = c & (a + b)...」) |
(→基本) |
||
| 行1: | 行1: | ||
| − | == | + | ==セルに値を返す== |
マクロのmodule1に以下を記述 | マクロのmodule1に以下を記述 | ||
| + | <pre> | ||
| + | public Function Test | ||
| + | Test = 1 | ||
| + | End Function | ||
| + | </pre> | ||
| + | セルに以下をいれると1が入る | ||
| + | =Test() | ||
| + | |||
| + | ==変数を使う== | ||
<pre> | <pre> | ||
public Function Test | public Function Test | ||
2023年2月17日 (金) 22:48時点における版
セルに値を返す
マクロのmodule1に以下を記述
public Function Test Test = 1 End Function
セルに以下をいれると1が入る
=Test()
変数を使う
public Function Test dim a as integer dim b as integer dim c as string c = "hello" a = 2 b = 1 Test = c & (a + b) End Function
セルに以下をいれるとhello3が入る
=Test()
