B
bobwilson
I use the below Code to copy data from specific cells to populate a
contact list. I'm trying to make the code review the existing customer
list base on Name to ensure that it is not adding a duplicate record
and if so I want to exit the macro before inserting data.
Sub newcontact()
With Application
ScreenUpdating = False
c_Database = "Contact List"
Dim indexnrcl As Integer
Dim namecl As String
Dim phonecl As String
Dim faxcl As String
Dim emailcl As String
Dim datecl As String
Dim commcl As String
Dim pstcl As String
Dim gstcl As String
indexnrcl = ActiveSheet.Range("b134")
namecl = ActiveSheet.Range("f105")
phonecl = ActiveSheet.Range("c106")
faxcl = ActiveSheet.Range("f106")
emailcl = ActiveSheet.Range("c107")
datecl = ActiveSheet.Range("c108")
commcl = ActiveSheet.Range("f108")
pstcl = ActiveSheet.Range("c109")
gstcl = ActiveSheet.Range("f109")
With Sheets(c_Database).Range("A" & indexnrcl + 1)
If Val(.Value) > 0 Then
MsgBox "A Record with Number " & indexnr & " already exists!"
Else
Value = indexnrcl
Offset(0, 1) = namecl
Offset(0, 2) = phonecl
Offset(0, 3) = faxcl
Offset(0, 4) = emailcl
Offset(0, 5) = datecl
Offset(0, 6) = commcl
Offset(0, 7) = pstcl
Offset(0, 8) = gstcl
End If
End With
End With
End Sub
contact list. I'm trying to make the code review the existing customer
list base on Name to ensure that it is not adding a duplicate record
and if so I want to exit the macro before inserting data.
Sub newcontact()
With Application
ScreenUpdating = False
c_Database = "Contact List"
Dim indexnrcl As Integer
Dim namecl As String
Dim phonecl As String
Dim faxcl As String
Dim emailcl As String
Dim datecl As String
Dim commcl As String
Dim pstcl As String
Dim gstcl As String
indexnrcl = ActiveSheet.Range("b134")
namecl = ActiveSheet.Range("f105")
phonecl = ActiveSheet.Range("c106")
faxcl = ActiveSheet.Range("f106")
emailcl = ActiveSheet.Range("c107")
datecl = ActiveSheet.Range("c108")
commcl = ActiveSheet.Range("f108")
pstcl = ActiveSheet.Range("c109")
gstcl = ActiveSheet.Range("f109")
With Sheets(c_Database).Range("A" & indexnrcl + 1)
If Val(.Value) > 0 Then
MsgBox "A Record with Number " & indexnr & " already exists!"
Else
Value = indexnrcl
Offset(0, 1) = namecl
Offset(0, 2) = phonecl
Offset(0, 3) = faxcl
Offset(0, 4) = emailcl
Offset(0, 5) = datecl
Offset(0, 6) = commcl
Offset(0, 7) = pstcl
Offset(0, 8) = gstcl
End If
End With
End With
End Sub