|
おはようございます。同じ質問をする事になるかもしれませんが、自分でも色々やってみましたが、今の自分の実力では下記コードを作る事が精一杯です・・・。
現在、フォーム上で入力した物を、ボタンクリックにより各シートへ移しています。シートは4つとも全く同じ物なのですが、これを、シートを1つにして、フォーム上にcomuboboxを作り、comboboxより名前選択すれば、その方の入力したものだけが、シート上へ移るようにしたいのですが・・・。
「IF」を利用して作るのかなぁと思い、試してはみたものの・・・・。
どうかお力をお貸し下さい。
Worksheets("一 郎").Select
For i = 5 To 46
Select Case i
Case 5 To 11: Cou = 11: Co = -3
Case 12 To 18: Cou = 13: Co = -10
Case 19 To 25: Cou = 15: Co = -17
Case 26 To 32: Cou = 17: Co = -24
Case 33 To 39: Cou = 19: Co = -31
Case 40 To 46: Cou = 21: Co = -38
End Select
Worksheets("一 郎").Cells(Cou, i + Co).Value = Me.Controls("TextBox" & i).Value
Next i
Worksheets("二 郎").Select
For i = 48 To 89
Select Case i
Case 48 To 54: Cou = 11: Co = -46
Case 55 To 61: Cou = 13: Co = -53
Case 62 To 68: Cou = 15: Co = -60
Case 69 To 75: Cou = 17: Co = -67
Case 76 To 82: Cou = 19: Co = -74
Case 83 To 89: Cou = 21: Co = -81
End Select
Worksheets("二 郎").Cells(Cou, i + Co).Value = Me.Controls("TextBox" & i).Value
Next i
Worksheets("三 郎").Select
For i = 91 To 132
Select Case i
Case 91 To 97: Cou = 11: Co = -89
Case 98 To 104: Cou = 13: Co = -96
Case 105 To 111: Cou = 15: Co = -103
Case 112 To 118: Cou = 17: Co = -110
Case 119 To 125: Cou = 19: Co = -117
Case 126 To 132: Cou = 21: Co = -124
End Select
Worksheets("三 郎").Cells(Cou, i + Co).Value = Me.Controls("TextBox" & i).Value
Next i
Worksheets("四 郎").Select
For i = 134 To 175
Select Case i
Case 134 To 140: Cou = 11: Co = -132
Case 141 To 147: Cou = 13: Co = -139
Case 148 To 154: Cou = 15: Co = -146
Case 155 To 161: Cou = 17: Co = -153
Case 162 To 168: Cou = 19: Co = -160
Case 169 To 175: Cou = 21: Co = -167
End Select
Worksheets("四 郎").Cells(Cou, i + Co).Value = Me.Controls("TextBox" & i).Value
Next i
For i = 43 To 84
Select Case i
Case 43 To 49: Cou = 10: Co = -41
Case 50 To 56: Cou = 12: Co = -48
Case 57 To 63: Cou = 14: Co = -55
Case 64 To 70: Cou = 16: Co = -62
Case 71 To 77: Cou = 18: Co = -69
Case 78 To 84: Cou = 20: Co = -76
End Select
Worksheets("一 郎").Cells(Cou, i + Co).Value = Me.Controls("label" & i).Caption
Worksheets("二 郎").Cells(Cou, i + Co).Value = Me.Controls("label" & i).Caption
Worksheets("三 郎").Cells(Cou, i + Co).Value = Me.Controls("label" & i).Caption
Worksheets("四 郎").Cells(Cou, i + Co).Value = Me.Controls("label" & i).Caption
Next i
|
|