#ユーザーフォーム作成
Sub ユーザーフォーム作成()
Dim myNewForm, myControl, n As Long
Set myNewForm = ActiveWorkbook.VBProject.VBComponents.Add(ComponentType:=3)
With myNewForm
.Properties("Height") = 240
.Properties("Width") = 180 + 12
.Properties("Caption") = "解析"
End With
For i = 1 To 5
Set myControl = myNewForm.Designer.Controls.Add("Forms.TextBox.1")
With myControl
.Left = 55 + 5
.Top = 5 + (i - 1) * 15
.Height = 15
.Width = 180 - 65
End With
Next
For i = 1 To 5
Set myControl = myNewForm.Designer.Controls.Add("Forms.Label.1")
With myControl
.Left = 5
.Top = 5 + (i - 1) * 15
.Height = 15
.Width = 50
.Caption = i
End With
Next
End Sub
##参考サイト
初期設定
https://nasunoblog.blogspot.com/2013/10/excel-vbavbprojectvbe.html
①http://officetanaka.net/excel/vba/vbe/07.htm#sample05
ラベルプロパティ
https://kosapi.com/post-3506/
https://ateitexe.com/excel-vba-add-userform-control/
https://www.excellovers.com/entry/2017/07/30/155613
http://pineplanter.moo.jp/non-it-salaryman/2017/05/04/vba-dynamic-control/
http://officetanaka.net/excel/vba/tips/tips112b.htm
https://qiita.com/tomochan154/items/3614b6f3ebc9ef947719