ผมต้องการให้รับจาก userform จาก Textbox1 โดยห้ามไม่ให้ค่าซ้ำกันใน คอลัม A:A ครับเเละถ้าพบว่าค่าซ้ำให้ให้ขึ้น Msgbox เตือนครับ รบกวนด้วยนะครับ
Private Sub CommandButton1_Click()
Dim onewrow As ListRow
Dim rng As Range
Set rng = ThisWorkbook.Worksheets("INVENTORY DATA").Range("inventory")
rng.Select
Set onewrow = Selection.ListObject.ListRows.Add(AlwaysInsert:=ture)
With ws
onewrow.Range.Cells(1, 1).Value = Me.TextBox1.Value
onewrow.Range.Cells(1, 2).Value = Me.TextBox3.Value
onewrow.Range.Cells(1, 3).Value = Me.ComboBox1.Value
onewrow.Range.Cells(1, 4).Value = Me.TextBox5.Value
onewrow.Range.Cells(1, 5).Value = Me.TextBox4.Value
onewrow.Range.Cells(1, 8).Value = Me.TextBox6.Value
End With
Me.TextBox1.Value = ""
Me.TextBox3.Value = ""
Me.ComboBox1.Value = ""
Me.TextBox5.Value = ""
Me.TextBox4.Value = ""
Me.TextBox6.Value = ""
End Sub
รบกวนช่วยเเก้ VBA รับค่าจาก Userform ไปใส่ในตาราง Excel โดยไม่ให้ข้อมูลซ้ำกันหน่อยครับ
Private Sub CommandButton1_Click()
Dim onewrow As ListRow
Dim rng As Range
Set rng = ThisWorkbook.Worksheets("INVENTORY DATA").Range("inventory")
rng.Select
Set onewrow = Selection.ListObject.ListRows.Add(AlwaysInsert:=ture)
With ws
onewrow.Range.Cells(1, 1).Value = Me.TextBox1.Value
onewrow.Range.Cells(1, 2).Value = Me.TextBox3.Value
onewrow.Range.Cells(1, 3).Value = Me.ComboBox1.Value
onewrow.Range.Cells(1, 4).Value = Me.TextBox5.Value
onewrow.Range.Cells(1, 5).Value = Me.TextBox4.Value
onewrow.Range.Cells(1, 8).Value = Me.TextBox6.Value
End With
Me.TextBox1.Value = ""
Me.TextBox3.Value = ""
Me.ComboBox1.Value = ""
Me.TextBox5.Value = ""
Me.TextBox4.Value = ""
Me.TextBox6.Value = ""
End Sub