ユーザーは一度に最大 10 人のメンバーを入力できます。列Aは「チーム名」になります 列Bは「メンバーの数」になります 列Cは「メンバー名」になります If Elseでは機能しますが、10回行うのは面倒です。If Else から For ループに変更する方法がわかりません
'Using If Else
Dim RowCount As Long
RowCount = Worksheets("Sheet1").Range("A1").CurrentRegion.Rows.Count
If txtNoMember.Value = 1 Then
With Worksheets("Sheet1").Range("A1")
.Offset(RowCount, 0).Value = txtTeamName.Text
.Offset(RowCount, 1).Value = txtNoMember.Text
.Offset(RowCount, 2).Value = txtMember01.Text
End With
ElseIf txtNoMember.Value = 2 Then
With Worksheets("Sheet1").Range("A1")
.Offset(RowCount, 0).Value = txtTeamName.Text
.Offset(RowCount, 1).Value = txtNoMember.Text
.Offset(RowCount, 2).Value = txtMember01.Text
.Offset(RowCount + 1, 0).Value = txtTeamName.Text
.Offset(RowCount + 1, 1).Value = txtNoMember.Text
.Offset(RowCount + 1, 2).Value = txtMember02.Text
End With
End If
'Using For Loop
Dim counter As Integer
Dim times As Integer
Dim RowCount As Long
RowCount = Worksheets("Sheet1").Range("A1").CurrentRegion.Rows.Count
For counter = 1 To txtNoMember.Value
times = txtNoMember.Value - 1
With Worksheets("Sheet1").Range("A1")
.Offset(RowCount + times, 0).Value = txtTeamName.Text
.Offset(RowCount + times, 1).Value = txtNoMember.Text
.Offset(RowCount + times, 2).Value = txtMember01.Text
End With