dear,
This is the code used by me to save to excell, its working, but i want to know duplicates value if there in Wroksheet("Group").
Private Sub CommandButton1_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("GROUP")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for a part number
If Trim(Me.txtgroup.Value) = "" Then
Me.txtgroup.SetFocus
MsgBox "PLEASE ENTER GROUP NAME", vbInformation
Exit Sub
End If
ANSWER = MsgBox("DO YOU WANT TO SAVE", vbYesNo)
If ANSWER = vbNo Then Exit Sub
'copy the data to the database
ws.Cells(iRow, 1).Value = ws.Cells(iRow - 1, 1).Value + 1
ws.Cells(iRow, 2).Value = Me.txtgroup.Value
'clear the data
Me.txtgroup.Value = ""
End Sub