snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
Private Sub BTsearch_Click()
On Error Resume Next
'Err.Clear
Dim nRow As String
nRow = Sheet6.Columns(1).Find(txtsearch.Text).Row
If Err.Number = 91 Then
TextBox2.Value = " "
MsgBox "ไม่มีข้อมูล"
End If
TextBox2.Value = Cells(nRow, 2)
End Sub
Private Sub BTsearch_Click()
Dim txt As String
On Error Resume Next
'Err.Clear
Dim nRow As String
nRow = Sheet6.Columns(1).Find(txtsearch.Text).Row
If Err.Number = 91 Then
TextBox1.RowSource = "txtsearch.Text"
MsgBox "ไม่มีข้อมูล"
End If
txt = Cells(nRow, 1) & vbCrLf & Cells(nRow, 3) & vbCrLf & Cells(nRow, 8) _
& vbCrLf & Cells(nRow, 13)
TextBox1.Value = txt
End Sub
Private Sub BTsearch_Click()
Dim txt As String
On Error Resume Next
'Err.Clear
Dim nRow As String
nRow = Sheet6.Columns(1).Find(txtsearch.Text).Row
If Err.Number = 91 Then
TextBox1.RowSource = "txtsearch.Text"
MsgBox "ไม่มีข้อมูล"
End If
txt = Cells(nRow, 1) & vbCrLf & Cells(nRow, 3) & vbCrLf & Cells(nRow, 8) _
& vbCrLf & Cells(nRow, 13)
TextBox1.Value = txt
End Sub
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
TextBox1.Value = "ชุดหดและเก่าตามสภาพ"
Else
TextBox1.Value = ""
End If
End Sub
Private Sub CheckBox2_Click()
If CheckBox2.Value = True Then
TextBox1.Value = "ชุดเปื่อยขาดเนื่องจากการซัก"
Else
TextBox1.Value = ""
End If
End Sub
Private Sub CheckBox3_Click()
If CheckBox3.Value = True Then
TextBox1.Value = "ชุดขาดตารอยตะเข็บ"
Else
TextBox1.Value = ""
End If
End Sub
Private Sub CheckBox4_Click()
If CheckBox4.Value = True Then
TextBox1.Value = "เดินทางไปทำงานต่างจังหวัด/ต่างประเทศ"
Else
TextBox1.Value = ""
End If
End Sub
Private Sub CheckBox5_Click()
If CheckBox5.Value = True Then
TextBox1.Value = "อื่นๆ"
Else
TextBox1.Value = ""
End If
End Sub
You do not have the required permissions to view the files attached to this post.
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
TextBox1.Value = "ชุดหดและเก่าตามสภาพ"
Else[attachment=2]ชื่อ1.png[/attachment][attachment=1]ชื่อ2.png[/attachment]
TextBox1.Value = ""
End If
End Sub
Private Sub CheckBox2_Click()
If CheckBox2.Value = True Then
TextBox1.Value = "ชุดเปื่อยขาดเนื่องจากการซัก"
Else
TextBox1.Value = ""
End If
End Sub
Private Sub CheckBox3_Click()
If CheckBox3.Value = True Then
TextBox1.Value = "ชุดขาดตารอยตะเข็บ"
Else
TextBox1.Value = ""
End If
End Sub
Private Sub CheckBox4_Click()
If CheckBox4.Value = True Then
TextBox1.Value = "เดินทางไปทำงานต่างจังหวัด/ต่างประเทศ"
Else
TextBox1.Value = ""
End If
End Sub
Private Sub CheckBox5_Click()
If CheckBox5.Value = True Then
TextBox1.Value = "อื่นๆ"
Else
TextBox1.Value = ""
End If
End Sub
[/quote]
You do not have the required permissions to view the files attached to this post.
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
TextBox1.Value = TextBox1.Value & vbCrLf & "ชุดหดและเก่าตามสภาพ"
' Else
' TextBox1.Value = ""
End If
End Sub
ที่บอกว่าคลิก OK แล้วให้ข้อความไปแสดงใน UserForm2 ก่อนอื่นต้องสร้างตัวแปรให้เก็บค่าใน TextBox1 เสียก่อน เป็นตัวแปรแบบ public และควรประกาศตัวแปรไว้บรรทัดบนสุดที่ modult1 ไม่ใช่ใน UserForm
Private Sub CheckBox1_Click()
Dim nRow As String
nRow = Sheet6.Columns(1).Find(txtsearch.Text).Row
If CheckBox1.Value = True Then
TextBox1.Value = TextBox1.Value & vbCrLf & "ชุดหดและเก่าตามสภาพ"
Else
If CheckBox1.Value = False Then
TextBox1.Value = Cells(nRow, 1) & vbCrLf & Cells(nRow, 2) & vbCrLf & Cells(nRow, 8) _
& vbCrLf & Cells(nRow, 13)
Else
End If
End If
End Sub
Private Sub combobox1_Change()
Dim nRow As String
nRow = Sheet6.Columns(1).Find(txtsearch.Text).Row
If Combobox1.Value = True Then
TextBox1.Value = TextBox1.Value & vbCrLf & "combobox1.Value"
Else
If TextBox1.Value = False Then
TextBox1.Value = Cells(nRow, 1) & vbCrLf & Cells(nRow, 2) & vbCrLf & Cells(nRow, 8) _
& vbCrLf & Cells(nRow, 13)
End If
End If
End Sub
You do not have the required permissions to view the files attached to this post.
Private Sub CheckBox1_Click()
Dim nRow As String
nRow = Sheet6.Columns(1).Find(txtsearch.Text).Row
If CheckBox1.Value = True Then
TextBox1.Value = TextBox1.Value & vbCrLf & "ชุดหดและเก่าตามสภาพ"
Else
TextBox1.Value = Replace(TextBox1.Value, vbCrLf & "ชุดหดและเก่าตามสภาพ", "")
End If
End Sub
Private Sub CheckBox1_Click()
Dim nRow As String
nRow = Sheet6.Columns(1).Find(txtsearch.Text).Row
If CheckBox1.Value = True Then
TextBox1.Value = TextBox1.Value & vbCrLf & "ชุดหดและเก่าตามสภาพ"
Else
TextBox1.Value = Replace(TextBox1.Value, vbCrLf & "ชุดหดและเก่าตามสภาพ", "")
End If
End Sub
Dim nRow As String
nRow = Sheet6.Columns(1).Find(txtsearch.Text).Row
If Combobox1.Value = True Then
TextBox1.Value = TextBox1.Value & vbCrLf & "combobox1.Value"
Else
If TextBox1.Value = False Then
TextBox1.Value = Cells(nRow, 1) & vbCrLf & Cells(nRow, 2) & vbCrLf & Cells(nRow, 8) _
& vbCrLf & Cells(nRow, 13)
End If
End If
End Sub
Private Sub combobox1_Change()
Dim nRow As String
nRow = Sheet6.Columns(1).Find(txtsearch.Text).Row
If Combobox1.Value = True Then
TextBox1.Value = TextBox1.Value & vbCrLf & "combobox1.Value"
Else
If TextBox1.Value = False Then
TextBox1.Value = Cells(nRow, 1) & vbCrLf & Cells(nRow, 2) & vbCrLf & Cells(nRow, 8) _
& vbCrLf & Cells(nRow, 13)
End If
End If
End Sub
Dim nRow As Integer
nRow = Sheet6.Columns(1).Find(txtsearch.Text).Row
If Combobox1.Value <> "" Then
TextBox1.Value = TextBox1.Value & vbCrLf & Combobox1.Value
Else
If TextBox1.Value = False Then
TextBox1.Value = Cells(nRow, 1) & vbCrLf & Cells(nRow, 2) & vbCrLf & Cells(nRow, 8) _
& vbCrLf & Cells(nRow, 13)
End If
End If
สังเกตการประกาศตัวแปร ค่าบรรทัดเป็นตัวเลข จะไม่ประกาศเป็น String แต่ให้ประกาศเป็น Integer หรือ Long หรือ Single อย่างใดอย่างหนึ่งแล้วแต่ความเหมาะสม