自作コードスニペット集


コードスニペット作成マクロをもとにいくつか試作した。

残課題

結局個人用マクロブックに登録しておいても
個人用マクロブックのVBAProjectをアクティブにしておかないと呼び出せないのが若干不便なので
別ブックの作業Project上で軽々呼び出せるようにできないかな

コード

宣言エリア

Function SNI_宣言エリア()
  Debug.Print "' -------------------------------------------------"
  Debug.Print "' ■■■ このモジュールの説明 ■■■"
  Debug.Print "'"
  Debug.Print "' -------------------------------------------------"
  Debug.Print ""
  Debug.Print "Type ShObj"
  Debug.Print "  A As Worksheet"
  Debug.Print "  B As Worksheet"
  Debug.Print "  C As Worksheet"
  Debug.Print "End Type"
  Debug.Print "Dim Sh As ShObj"
  Debug.Print ""
  Debug.Print "Type RngObj"
  Debug.Print "  A As Range"
  Debug.Print "  B As Range"
  Debug.Print "  C As Range"
  Debug.Print "End Type"
  Debug.Print "Dim Rng As RngObj"
  Debug.Print ""
  Debug.Print "Type 先頭データ行"
  Debug.Print "  A As Long"
  Debug.Print "  B As Long"
  Debug.Print "  C As Long"
  Debug.Print "End Type"
  Debug.Print "Dim rH As 先頭データ行"
  Debug.Print ""
  Debug.Print "Enum c"
  Debug.Print "  あ = 1"
  Debug.Print "  い"
  Debug.Print "  う"
  Debug.Print "End Enum"
End Function

Rangeオブジェクト作成

Function SNI_Set_RngObj()
  Debug.Print "  Dim rFirst As Range"
  Debug.Print "  Dim rLast As Range"
  Debug.Print "  "
  Debug.Print "  Set rFirst ="
  Debug.Print "  Set rLast ="
  Debug.Print "  Set Rng = Range(rFirst, rLast)"
  Debug.Print ""
End Function

For i = 1 To UBound(Rangeオブジェクト.Value2)

Function SNI_For_RngObj()
  Debug.Print "  Dim i, j, k"
  Debug.Print "  For i = 1 To UBound(Rng.a.Value2)"
  Debug.Print "    For j = 1 To UBound(Rng.B.Value2)"
  Debug.Print "      For k = c. To c."
  Debug.Print "        "
  Debug.Print "      Next"
  Debug.Print "    Next"
  Debug.Print "  Next"
  Debug.Print ""
End Function

For Each r in Rangeオブジェクト

Function SNI_ForEach_r()
  Debug.Print "  Dim r As Range"
  Debug.Print "  For Each r In Rng"
  Debug.Print "    "
  Debug.Print "  Next"
End Function