回答編集履歴

1

コード追加

2020/03/10 15:35

投稿

hatena19
hatena19

スコア34075

test CHANGED
@@ -73,3 +73,63 @@
73
73
  End Sub
74
74
 
75
75
  ```
76
+
77
+
78
+
79
+ ---
80
+
81
+ 別案
82
+
83
+
84
+
85
+ ```vba
86
+
87
+ Private Sub UserForm_Initialize()
88
+
89
+ With ListBox1
90
+
91
+ .ColumnCount = 4
92
+
93
+ .ColumnWidths = "20;100;0;0"
94
+
95
+ End With
96
+
97
+
98
+
99
+ With ListBox2
100
+
101
+ .ColumnCount = 2
102
+
103
+ .ColumnWidths = "50;50"
104
+
105
+ End With
106
+
107
+
108
+
109
+ With Worksheets("リスト1").Range("A1").CurrentRegion
110
+
111
+ ListBox1.List = .Offset(1).Resize(.Rows.Count - 1, 4).Value
112
+
113
+ ListBox1.ListIndex = 0
114
+
115
+ End With
116
+
117
+ End Sub
118
+
119
+
120
+
121
+ Private Sub ListBox1_Click()
122
+
123
+ With ListBox1
124
+
125
+ ListBox2.Clear
126
+
127
+ ListBox2.AddItem .List(.ListIndex, 2)
128
+
129
+ ListBox2.List(0, 1) = .List(.ListIndex, 3)
130
+
131
+ End With
132
+
133
+ End Sub
134
+
135
+ ```