แสดงเฉพาะตัวเลขที่ไม่ซ้ำกันใน ComboBox2
untitled111.GIF
จากรูปคือ ต้องการให้ช่องที่ 1 (ComboBox1) โชว์ค่า เลขประจำตัวที่ไม่ซ้ำกัน (ทำได้ครับ)
ต้องการให้ช่องที่ 2 (ComboBox2) โชว์ค่า พศ.ที่ไม่ซ้ำกัน โดยอ้างอิงจาก ComboBox1 (ทำไม่ได้ครับ)
ชื่อฟอร์ม Form1SearchReport2
Code ที่ใช้กับ ช่องพัฒนาตนเองอยู่ด้านล่าง
Code: Select all
Private Sub OptionButton1_Click()
CommandButton1.Enabled = True
ComboBox1.Clear
Sheets("DataTrain").Select
Range("AA5").Select
MyComboBox1 = ActiveCell.Value
ComboBox1.AddItem MyComboBox1
ActiveCell.Offset(1, 0).Select
Do While Not IsEmpty(ActiveCell.Value)
If MyComboBox1 <> ActiveCell.Value Then
MyComboBox1 = ActiveCell.Value
ComboBox1.AddItem MyComboBox1
End If
ActiveCell.Offset(1, 0).Select
Loop
End Sub
โคดที่ใช้ Code ที่ใช้กัน ช่องหมายเลขประจำตัว
Code: Select all
Private Sub ComboBox1_Change()
Sheets("DataTrain").Select
ComboBox2.Clear
Range("AB5").Select
Do While Selection <> ""
If ComboBox2 = ActiveCell And ActiveCell.Offset(0, 1) = ActiveCell.Offset(-1, 1) Then
ComboBox3.AddItem ActiveCell.Offset(0, 1).Value
End If
ActiveCell.Offset(1, 0).Select
Loop
End Sub
ทั้งนี้ได้แนบไฟล์มาให้อาจาร์ยดู
You do not have the required permissions to view the files attached to this post.