Userform data entry

pujo

Well-known Member
Joined
Feb 19, 2009
Messages
708
Office Version
  1. 2019
  2. 2013
Platform
  1. Windows
I am utilizing a UserForm for data entry into a data range.
How can I ensure that a record doesn't get duplicated?

This is my logic for saving the record.
VBA Code:
'<------------------------- Save NewRecord in CostCenter Data ------------------------->
Private Sub cmdSave_Click()
Dim Sh As Worksheet
 Set Sh = ThisWorkbook.Worksheets("CostCenter")
 Dim lRow As Long
 lRow = Application.WorksheetFunction.CountA(Sh.Range("A:A"))
 
 Call RecordValidation '<-- Run Record Validation prior to Saving

'<------------------------- Write NewRecord to DataSheet ------------------------->
    Sh.Range("A" & lRow + 1).Value = textboxLocation.Value 'CostCenter (Location)
    Sh.Range("B" & lRow + 1).Value = textboxDescription.Value 'Description
    Sh.Range("C" & lRow + 1).Value = textboxCompany.Value 'Company ID
    Sh.Range("D" & lRow + 1).Value = textboxCostCenter.Value 'Cost Center ID
    Sh.Range("E" & lRow + 1).Value = "=Row()" 'Record ID (Row)

    Me.cmdNew.Visible = True
    Me.cmdDelete.Visible = True
    Me.cmdUpdate.Visible = True
    Me.cmdCancel.Visible = False
    Me.cmdSave.Visible = False
  MsgBox "Record Saved", vbInformation, "Cost Center"
   
End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,214,919
Messages
6,122,259
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top