回答編集履歴

1

追記

2020/03/12 10:19

投稿

mattuwan
mattuwan

スコア2163

test CHANGED
@@ -51,3 +51,91 @@
51
51
  ```
52
52
 
53
53
  こういうことがやりたいのかな?
54
+
55
+
56
+
57
+ ---
58
+
59
+
60
+
61
+ ```ExcelVBA
62
+
63
+ Option Explicit
64
+
65
+
66
+
67
+ Private Sub UserForm_Initialize()
68
+
69
+ With Worksheets(1).Range("A1").CurrentRegion
70
+
71
+ Me.ListBox1.List = Intersect(.Resize(, 7), .Offset(1, 1)).Value
72
+
73
+ End With
74
+
75
+ Me.ListBox1.MultiSelect = fmMultiSelectExtended
76
+
77
+ With Me.ListBox2
78
+
79
+ .ColumnCount = 4
80
+
81
+ .ColumnWidths = "20;20;20;20"
82
+
83
+ End With
84
+
85
+ End Sub
86
+
87
+
88
+
89
+ Private Sub ListBox1_Change()
90
+
91
+ Dim ix As Long
92
+
93
+ Dim v As Variant
94
+
95
+ Dim i As Long, j As Long
96
+
97
+
98
+
99
+ Me.ListBox2.Clear
100
+
101
+
102
+
103
+ With Me.ListBox1
104
+
105
+ For ix = 0 To .ListCount - 1
106
+
107
+ If .Selected(ix) Then
108
+
109
+ Me.ListBox2.AddItem ""
110
+
111
+ i = 0
112
+
113
+ j = 0
114
+
115
+ For Each v In WorksheetFunction.Index(.List, ix + 1, 0)
116
+
117
+ j = j + 1
118
+
119
+ If j <> 3 Then
120
+
121
+ Me.ListBox2.List(Me.ListBox2.ListCount - 1, i) = v
122
+
123
+ i = i + 1
124
+
125
+ End If
126
+
127
+ Next
128
+
129
+ End If
130
+
131
+ Next
132
+
133
+ End With
134
+
135
+ End Sub
136
+
137
+ ```
138
+
139
+
140
+
141
+ 説明の言葉が難しくてよくわかんないけど。。。