คำถามด้านบนทำได้แล้วรบกวนดูโค้ดบันทึกข้อมูลหน่อยค่ะ
เมื่อเลือกข้อมูลใน optionbutton แล้วข้อมูลไม่ถูกบันทึกลงในชีท 9 "การเบิก" ค่ะ
Code: Select all
Private Sub btsave_Click()
'On Error Resume Next
If TextBox1 = "" Or TextBox3 = "" Then
MsgBox "กรุณากรอกข้อมูลให้ครบถ้วน"
Exit Sub
End If
Dim emptyRow As Integer
Dim ct As Object
Dim strTb1 As Variant
Dim strTb3 As Variant
opt = OptionButton1.Value Or OptionButton2.Value
emptyRow = WorksheetFunction.CountA(Sheet9.Range("A3:A10000")) + 1
'emptyRow = WorksheetFunction.Count("A3:A10000") + 1
If emptyRow = 0 Then
emptyRow = 2
Else
emptyRow = emptyRow + 2
Sheet9.Activate
strTb1 = Split(TextBox1.Text, vbCrLf)
strTb3 = TextBox3.Text & vbCrLf
strTb3 = strTb3 & vbCrLf
strTb3 = strTb3 & vbCrLf
strTb3 = Split(strTb3, vbCrLf)
Cells(emptyRow, 1).Value = VBA.Mid(strTb1(0), InStr(strTb1(0), ":") + 1) 'TextBox1.Value
Cells(emptyRow, 2).Value = VBA.Mid(strTb1(1), InStr(strTb1(1), ":") + 1) 'TextBox1.Value
Cells(emptyRow, 3).Value = VBA.Mid(strTb1(2), InStr(strTb1(2), ":") + 1) 'TextBox1.Value
Cells(emptyRow, 4).Value = VBA.Mid(strTb1(3), InStr(strTb1(3), ":") + 1) 'TextBox1.Value
Cells(emptyRow, 6).Value = strTb3(0) & "," & strTb3(1) & "," & strTb3(2) 'TextBox3.Value
Cells(emptyRow, 7).Value = strTb3(3) & "," & strTb3(4) & "," & strTb3(5)
Cells(emptyRow, 8).Value = strTb3(6) & "," & strTb3(7)
If OptionButton1.Value = True Then
Cells(CurrentRow, 10).Value = "มารับแล้ว"
ElseIf OptionButton2.Value = True Then
Cells(CurrentRow, 10).Value = "ไม่ได้มารับ"
ElseIf OptionButton3.Value = True Then
Cells(CurrentRow, 10).Value = TextBox15.Value
End If
If OptionButton4.Value = True Then
Cells(CurrentRow, 9).Value = "ชุดหดและเก่าตามสภาพ"
ElseIf OptionButton5.Value = True Then
Cells(CurrentRow, 9).Value = "ชุดเปื่อยขาด เนื่องจากการซัก"
ElseIf OptionButton6.Value = True Then
Cells(CurrentRow, 9).Value = "ชุดขาดตามรอยตะเข็บ"
ElseIf OptionButton7.Value = True Then
Cells(CurrentRow, 9).Value = "เดินทางไปต่างจังหวัด/ต่างประเทศ"
ElseIf OptionButton8.Value = True Then
Cells(CurrentRow, 9).Value = TextBox2.Value
End If
Cells(emptyRow, 5).Value = comday.Value & "/" & commonth.Value & "/" & comyear.Value
MsgBox "บันทึกข้อมูลเรียบร้อยแล้ว"
Unload Me
UserForm1.Show
End If
'Sheet1.Activate
End Sub
You do not have the required permissions to view the files attached to this post.