1
3

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 5 years have passed since last update.

【VBA】ユーザーフォームをVBAで作成

Last updated at Posted at 2019-05-28

#ユーザーフォーム作成

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

1
3
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
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?