Thread: Macro Help!!!
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Macro Help!!!

The data must match!!!! Look at the message closely and see what the the
data that is displayed in the message box. You may be comparing 2 blank
cells which will allow the message box to display.

"Arran" wrote:

Hi to all,

I have got some code that copies cells from one sheet to another, if there
is a duplicate a message pops up stating that there is a duplicate and exits
the macro, my problem is that if the data isn't duplicated, the message box
still pops up:

MLRow = 4 'MasterList Start Row

Do Until ThisWorkbook.Sheets("Data Base").Cells(MLRow, 3) = ""
If DBWks.Cells(MLRow, 3).Value = NewFormWks.Cells(7, 4).Value Then
MsgBox ("Duplicated Record: " & vbNewLine & vbNewLine & "Contract
Number: " & _
NewFormWks.Cells(7, 4).Value & " already exists")
NewFormWkbk.Close
Exit Sub
MLRow = 5
Exit Do
End If
MLRow = MLRow + 1

If DBWks.Cells(MLRow, 3).Value = "" Then
DBWks.Cells(MLRow, 2).Value = NewFormWks.Cells(5, 7).Value
'Division
DBWks.Cells(MLRow, 3).Value = NewFormWks.Cells(7, 4).Value
'Contract No

End If
Loop

How can I stop this from happening? Any help will be welcome.

Thanks in advance