|
▼kanabun さん:
すませんでした。
長い構文になりますが張りますのでよろしくお願いいたします。
TextBox76:累計時間(TextBox77+TextBox78+TextBox82)
TextBox50-49=TextBox78(小計時間)
TextBox54-53=TextBox77(小計時間)
TextBox57-56=TextBox82(小計時間)
TextBox70、71、72(DATE:日付)
TextBox52、55、58(コメント)
になります。
CommandButton36_Click()はワークシート(DATA)に飛ばす
構文は以下の通りです。
-------------------------------------------------------------
Private Sub CommandButton36_Click()
Dim lRow As Long
Number = TextBox3
With Worksheets("DATA")
'フォームからエクセルに出力
If TextBox76.Value = "" Then
lRow = .Range("J" & Rows.Count).End(xlUp).Row
.Range("J" & lRow + 1).Value = lRow
Else
lRow = .Range("J" & Rows.Count).End(xlUp).Row
Worksheets("DATA").Range("J1").Offset(Number, 0).Value = TextBox76.Value
End If
If TextBox70.Value = "" Then
lRow = .Range("M" & Rows.Count).End(xlUp).Row
.Range("M" & lRow + 1).Value = lRow
Else
lRow = .Range("M" & Rows.Count).End(xlUp).Row
Worksheets("DATA").Range("M1").Offset(Number, 0).Value = TextBox70.Value
End If
If TextBox49.Value = "" Then
lRow = .Range("N" & Rows.Count).End(xlUp).Row
.Range("N" & lRow + 1).Value = lRow
Else
lRow = .Range("N" & Rows.Count).End(xlUp).Row
Worksheets("DATA").Range("N1").Offset(Number, 0).Value = TextBox49.Value
End If
If TextBox50.Value = "" Then
lRow = .Range("O" & Rows.Count).End(xlUp).Row
.Range("O" & lRow + 1).Value = lRow
Else
lRow = .Range("O" & Rows.Count).End(xlUp).Row
Worksheets("DATA").Range("O1").Offset(Number, 0).Value = TextBox50.Value
End If
If TextBox52.Value = "" Then
lRow = .Range("P" & Rows.Count).End(xlUp).Row
.Range("P" & lRow + 1).Value = lRow
Else
lRow = .Range("P" & Rows.Count).End(xlUp).Row
Worksheets("DATA").Range("P1").Offset(Number, 0).Value = TextBox52.Value
End If
If TextBox78.Value = "" Then
lRow = .Range("Q" & Rows.Count).End(xlUp).Row
.Range("Q" & lRow + 1).Value = lRow
Else
lRow = .Range("Q" & Rows.Count).End(xlUp).Row
Worksheets("DATA").Range("Q1").Offset(Number, 0).Value = TextBox78.Value
End If
If TextBox71.Value = "" Then
lRow = .Range("R" & Rows.Count).End(xlUp).Row
.Range("R" & lRow + 1).Value = lRow
Else
lRow = .Range("R" & Rows.Count).End(xlUp).Row
Worksheets("DATA").Range("R1").Offset(Number, 0).Value = TextBox71.Value
End If
If TextBox53.Value = "" Then
lRow = .Range("S" & Rows.Count).End(xlUp).Row
.Range("S" & lRow + 1).Value = lRow
Else
lRow = .Range("S" & Rows.Count).End(xlUp).Row
Worksheets("DATA").Range("S1").Offset(Number, 0).Value = TextBox53.Value
End If
If TextBox54.Value = "" Then
lRow = .Range("T" & Rows.Count).End(xlUp).Row
.Range("T" & lRow + 1).Value = lRow
Else
lRow = .Range("T" & Rows.Count).End(xlUp).Row
Worksheets("DATA").Range("T1").Offset(Number, 0).Value = TextBox54.Value
End If
If TextBox55.Value = "" Then
lRow = .Range("U" & Rows.Count).End(xlUp).Row
.Range("U" & lRow + 1).Value = lRow
Else
lRow = .Range("U" & Rows.Count).End(xlUp).Row
Worksheets("DATA").Range("U1").Offset(Number, 0).Value = TextBox55.Value
End If
If TextBox57.Value = "" Then
lRow = .Range("U" & Rows.Count).End(xlUp).Row
.Range("U" & lRow + 1).Value = lRow
Else
lRow = .Range("U" & Rows.Count).End(xlUp).Row
Worksheets("DATA").Range("U1").Offset(Number, 0).Value = TextBox55.Value
End If
If TextBox77.Value = "" Then
lRow = .Range("V" & Rows.Count).End(xlUp).Row
.Range("V" & lRow + 1).Value = lRow
Else
lRow = .Range("V" & Rows.Count).End(xlUp).Row
Worksheets("DATA").Range("V1").Offset(Number, 0).Value = TextBox77.Value
End If
If TextBox72.Value = "" Then
lRow = .Range("W" & Rows.Count).End(xlUp).Row
.Range("W" & lRow + 1).Value = lRow
Else
lRow = .Range("W" & Rows.Count).End(xlUp).Row
Worksheets("DATA").Range("W1").Offset(Number, 0).Value = TextBox72.Value
End If
If TextBox56.Value = "" Then
lRow = .Range("X" & Rows.Count).End(xlUp).Row
.Range("X" & lRow + 1).Value = lRow
Else
lRow = .Range("X" & Rows.Count).End(xlUp).Row
Worksheets("DATA").Range("X1").Offset(Number, 0).Value = TextBox56.Value
End If
If TextBox58.Value = "" Then
lRow = .Range("Z" & Rows.Count).End(xlUp).Row
.Range("Z" & lRow + 1).Value = lRow
Else
lRow = .Range("Z" & Rows.Count).End(xlUp).Row
Worksheets("DATA").Range("Z1").Offset(Number, 0).Value = TextBox58.Value
End If
If TextBox82.Value = "" Then
lRow = .Range("AA" & Rows.Count).End(xlUp).Row
.Range("AA" & lRow + 1).Value = lRow
Else
lRow = .Range("AA" & Rows.Count).End(xlUp).Row
Worksheets("DATA").Range("AA1").Offset(Number, 0).Value = TextBox82.Value
End If
End With
End Sub
------------------------------------------------------------------------------------
ここで
TextBox(小計時間)
TextBox(DATE:日付)
TextBox(コメント)が未入力の場合にワークシートに00:00が飛んでしまいます。
未入力の場合の時にこの様な不要なデータが飛ばない様にするには構文をどの様に追加
すればよいでしょうか・・?
|
|