VBA Code Improvement - Restricting duplicate entry if available in another range

  • Hi Experts


    Good day;


    The following code helps me to restrict duplicate entry in a cell if available in another cell. I want to increase the check to a certain range.



    Thanks in Advance

  • Re: VBA Code Improvement - Restricting duplicate entry if available in another range


    the below code will run till the last range so not sure what the issue is


    Code
    Last_Row_DocType = Sheets("A").Range("B1").End(xlDown).Row 
     Last_Row_DocNo = Sheets("A").Range("C1").End(xlDown).Row
  • Re: VBA Code Improvement - Restricting duplicate entry if available in another range


    Thanks Redli for the quick response


    As per the below mentioned code, i have defined a range Doctype and Docno, its just a single cell ("B1") and ("C1") respectively. The issue is that i need increase the range Doctype and Docno to an complete row or multiple cells like ("B1:B10000") and ("C1:C10000") . If condition should check the entire cells not just a particular cell.


    Basically am trying to restrict running the code if any entry in one cell is already available there in another sheet in a particular row or multiple cell.


    Code
    Doctype = Sheets("A").Range("B1")
    Docno = Sheets("A").Range("C1") 
        If Sheets("B").Range("I3") = Doctype And Sheets("B").Range("J3") = Docno Then 
            MsgBox "This document number already exist, Please correct your document Number"

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!