2次元配列のサイズを取得する この関数は、2次元配列の要素の数を計算します。 SubtestArrySize()Dimarr2D(1To4,1To4)AsLongMsgBox GetArrSize_2D(arr2D)EndSubPublicFunctionGetArrSize_2D(aAsVariant)AsLongDimxAsLong,yAsLongIfIsEmpty(a)ThenGetArrSize_2D=0Elsex=UBound(a,1)-LBound(a,1)+1y=UBou...
To3,1To2)AsVariantDimoutputArrAsVariant'配列の値を代入するtempArr(1,1)="Steve"tempArr(1,2)="Johnson"tempArr(2,1)="Ryan"tempArr(2,2)="Johnson"tempArr(3,1)="Andrew"tempArr(3,2)="Scott"'転置関数を呼び出すoutputArr=TransposeArray(testArr)'テスト出力MsgBox outputArr(2,1)EndSub...
FunctionTestMacro() MsgBox ActiveWorkbook.NameEndFunctionSubAddUDFToCustomCategory() Application.MacroOptions Macro:="TestMacro", Category:="My Custom Category"EndSub サポートとフィードバック Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィ...
PrivateSubWorkbook_Open() Application.OnKey"{F9}","Recalc"EndSub このサブルーチンを標準モジュールに追加します。 VBコピー SubRecalc() Application.Calculate MsgBox"hello"EndSub オートメーション アドイン (Excel 2002 以降のバージョン) のユーザー定義関数は...
' 引数: i Long ' wName String ' Private Sub copyTargetWeatherIcon(ByVal i As Long, ByVal wName As String) On Error GoTo ErrHdl Dim isp As Shape, dCell As Range, osp As Shape ' コピー元図形をセット Set isp = IconSheet.Shapes(wName) ...
Sub コマンド実行() Dim targetCell: Set targetCell = ActiveCell Dim result As CommandOutput: result = コマンド実行関数(targetCell.Value) 上記部分は選択したセルの値をコマンド実行関数の引数として渡して呼び出してます。 選択したセルはActiveCellで取得してから一時変数targetCellに格納し、Value...
VBA では,次のスクリプトを実行して複数のヘッダーとフッターを設定します. Public Sub PathAndFileNameInFooter() Dim wsSht As Worksheet For Each wsSht In ActiveWindow.SelectedSheets wsSht.PageSetup.LeftFooter = ActiveWorkbook.FullName Next wsSht End Sub AppleScript では次のようになります. ...
VBAでFormatDateTime関数を使用して、日付または時刻をコンピューターの地域の設定で指定されている形式に従った文字列型に変換する方法をご説明します。コンピューターの地域の設定を生かすケースがあまりないと思いますが、国を跨いだ日本
VBA の Time 関数よりも高速かつ正確なタイマが必要です。 次の例に示す MICROTIMER() 関数は、システムの高分解能タイマへの Windows API 呼び出しを使用します。 このタイマでは、時間の間隔をマイクロ秒の小数部分まで計測できます。 Windows はマルチ タスクのオペレーティング システムで...