This is my original code to send data sheet
Private Sub CommandButton1_Click()
If RATE.TextBox5.Value = "" Then Exit Sub
With Application
.EnableEvents = False
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
Dim UserForm As Object
Dim emptyRow As Long
Dim ws As Worksheet
Set ws = Worksheets("RATE")
emptyRow = Application.WorksheetFunction.CountA(Range("J:J")) + 1
ws.Cells(emptyRow, 10).Value = Me.TextBox1.Value
ws.Cells(emptyRow, 11).Value = Me.TextBox2.Value
ws.Cells(emptyRow, 12).Value = Me.TextBox3.Value
ws.Cells(emptyRow, 13).Value = Me.TextBox4.Value
ws.Cells(emptyRow, 14).Value = Me.TextBox5.Value
With Application
.EnableEvents = True
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
ComboBox2.SetFocus
End Sub
and change this one to avoid duplicate entry, i apply this only textbox2 and its working ok, now i also want to apply this code to textbox1, textbox2, textbox3 and textbox4
If IsError(Application.Match(TextBox2.Text, Worksheets("RATE").Range("k2:k" & Worksheets("RATE").Cells(Rows.Count, "k").End(xlUp).Row), 0)) Then
Private Sub CommandButton1_Click()
If RATE.TextBox5.Value = "" Then Exit Sub
With Application
.EnableEvents = False
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
Dim UserForm As Object
Dim emptyRow As Long
Dim ws As Worksheet
Set ws = Worksheets("RATE")
emptyRow = Application.WorksheetFunction.CountA(Range("J:J")) + 1
If IsError(Application.Match(TextBox2.Text, Worksheets("RATE").Range("k2:k" & Worksheets("RATE").Cells(Rows.Count, "k").End(xlUp).Row), 0)) Then
ws.Cells(emptyRow, 10).Value = Me.TextBox1.Value
ws.Cells(emptyRow, 11).Value = Me.TextBox2.Value
ws.Cells(emptyRow, 12).Value = Me.TextBox3.Value
ws.Cells(emptyRow, 13).Value = Me.TextBox4.Value
ws.Cells(emptyRow, 14).Value = Me.TextBox5.Value
Else: Exit Sub
End If
With Application
.EnableEvents = True
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
ComboBox2.SetFocus
End Sub
Bookmarks