100%(3)100% нашли этот документ полезным (3 голоса)
5K просмотров1 страница
This document provides code to paste into Excel VBA to check a range of cells for duplicate values. The code defines the target range to watch, uses Find to check if the active cell's value exists elsewhere in the column, and if so clears the active cell and displays a message.
Исходное описание:
with the help of this code you can define primay key/field in Ms-Excel
This document provides code to paste into Excel VBA to check a range of cells for duplicate values. The code defines the target range to watch, uses Find to check if the active cell's value exists elsewhere in the column, and if so clears the active cell and displays a message.
Авторское право:
Attribution Non-Commercial (BY-NC)
Доступные форматы
Скачайте в формате TXT, PDF, TXT или читайте онлайн в Scribd
This document provides code to paste into Excel VBA to check a range of cells for duplicate values. The code defines the target range to watch, uses Find to check if the active cell's value exists elsewhere in the column, and if so clears the active cell and displays a message.
Авторское право:
Attribution Non-Commercial (BY-NC)
Доступные форматы
Скачайте в формате TXT, PDF, TXT или читайте онлайн в Scribd
open excel the press alt+f11 then dbclick on required sheet and paste the
following code
private sub worksheet_change(byval target as range)
dim targ as range, cel as range, rg as range set targ = [d:d] 'change to the cell range being watched for duplicates set targ = intersect(targ, target) if targ is nothing then exit sub
for each cel in targ.cells
if cel <> "" then set rg = columns(cel.column).find(cel, lookin:=xlvalues, after:=cel) if rg.address <> cel.address then application.enableevents = false cel = "" cel.select application.enableevents = true msgbox "duplicate entry! " & cel.value end if end if next end sub