r = 11
Do While Not tgtWSheet.Cells(r, 2) = "0"
If tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 1, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 2, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 3, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 4, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 5, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 6, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 7, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 8, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 9, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 10, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 11, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 12, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 13, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 14, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 15, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 16, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 17, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 18, 2) Then
MsgBox "Duplicate Record Found!"
Exit Sub
Else
r = r + 1
End If
Loop
标签:
excel-vba-mac
相关问题
- VBA code to fetch data from Mysql DB in Mac Excel
- Excel Macro Multiple Sheets to CSV
- How to develop an Excel Macro that contains regula
- The MacScript function is not working well in Offi
- Create a folder and sub folder in Excel VBA
相关文章
- VBA code to fetch data from Mysql DB in Mac Excel
- Excel Macro Multiple Sheets to CSV
- How to develop an Excel Macro that contains regula
- The MacScript function is not working well in Offi
- Create a folder and sub folder in Excel VBA
- How do I issue an HTTP GET from Excel VBA for Mac
- Checking if a worksheet-based checkbox is checked
- 在Excel 2010中刷新BackgroundQuery运行时错误1004(run time er
I think you should try "And" instead of "Or". The reason is because of a logic issue. I think someone has asked this question before. You can refer to the following post for some help.
check a record for Duplicates Records, Before Creating New Records
Anyway, his chain of thought is to give a name to the column and check if there is any duplicate in the row using the following formula.
Hope it helps.