|
▼カウボーイズ さん:
ありがとうございます。
この場合親を指定するのですね。
さっそくUserForm1と2箇所に加筆しました。
ですが今度は、Null値のつかいかたが不正とでます。
どこかがまだいけないのでしょうか。
(標準モジュール)
Option Explicit
Public i As Long
Public ws1 As Worksheet
Public MyCount As Integer
Public n As Long
Sub Sample()
With UserForm1.ListBox1 '←UserForm1と加筆しました
MyCount = UserForm1.ListBox1 - 1 '←UserForm1と加筆しました。が、Null値のつかいかたが不正とでます。
For n = 0 To MyCount
If (.Selected(n) = True) Then
If Not Application.Intersect(Range("C3:C104"), ActiveCell) Is Nothing Then
Set ws1 = Worksheets("history")
i = ws1.Range("B65536").End(xlUp).Row + 1
If i < 5 Then
i = 5
End If
With ActiveCell
ws1.Cells(i, 2).Resize(, 3).Value = Array(.Offset(, -1).Value, .Value, .Offset(, 3).Value)
ws1.Cells(i, 2).Offset(, 7).Value = .Offset(, 5).Value
End With
UserForm1.Show
Else
MsgBox "Programのいずれかを選択してください。"
End If
End If
Next n
End With
End Sub
(ユーザフォーム)
Option Explicit
Private Sub UserForm_Initialize()
Calendar1.Value = Date
' カレンダーの日付をセルにセットする
Dim i As Integer
Me.ListBox1.RowSource = Worksheets("member").Range("a2:a51").Address(external:=True) '←追加しました
Me.TextBox1.Value = Date
With Me.ComboBox1
For i = 1 To 24
.AddItem i
Next
End With
With Me.ComboBox2
For i = 0 To 45 Step 15
.AddItem i
Next
End With
With Me.ComboBox3
For i = 1 To 24
.AddItem i
Next
End With
With Me.ComboBox4
For i = 0 To 45 Step 15
.AddItem i
Next
End With
End Sub
Private Sub Calendar1_Click()
TextBox1.Value = Calendar1.Value
' カレンダーの日付をセルにセットする
End Sub
Private Sub CommandButton1_Click()
Dim From_Str As String
Dim To_Str As String
Dim Hours As Double
If Me.ComboBox1.Value <> "" And Me.ComboBox2.Value <> "" Then
From_Str = Me.ComboBox1.Value & ":" & Me.ComboBox2.Value
End If
If Me.ComboBox3.Value <> "" And Me.ComboBox4.Value <> "" Then
To_Str = Me.ComboBox3.Value & ":" & Me.ComboBox4.Value
End If
If From_Str <> "" And To_Str <> "" Then
Hours = (CDate(To_Str) - CDate(From_Str)) * 24
'Date
ws1.Cells(i, 5).Value = Me.TextBox1.Value
'Time(From)
ws1.Cells(i, 6).Value = CDate(From_Str)
'Time(To)
ws1.Cells(i, 7).Value = CDate(To_Str)
'Hours
ws1.Cells(i, 8).Value = (CDate(To_Str) - CDate(From_Str)) * 24
'Place
ws1.Cells(i, 10).Value = Me.TextBox2.Value
'Notese
ws1.Cells(i, 11).Value = Me.TextBox3.Value
End If
Unload UserForm1
End Sub
Private Sub UserForm_Deactivate()
Unload UserForm1
End Sub
|
|