Use the match function,
application.worksheetfunction.match, its the same layout as in workbook formula, if it errors its ok, if it doesnt error then theres a match
public function BarcodeDupe(strBarcode as string) as boolean
BarcodeDupe =false
on error goto eHandle
if application.worksheetfunction.match(strBarcode ,worksheets("Stock List").range("B:B")>0 then
BarcodeDupe =true
end if
exit function
eHandle:
end function
in your macro then, the first line woudl be
if BarcodeDupe(range("d7")) then msgbox("DUPLICATE")
UNTESTED
Bookmarks