+ Reply to Thread
Results 1 to 3 of 3

How can I avoid duplicates based on multiple cells with Userform VBA?

  1. #1
    Registered User
    Join Date
    11-09-2019
    Location
    Milan, Italy
    MS-Off Ver
    office 365
    Posts
    69

    How can I avoid duplicates based on multiple cells with Userform VBA?

    Hello everybody,

    I need to insert data in a worksheet by use of a Userform. Before the data is inserted I need to check if multiple cells already contain the data I have in the Userform. In my case a duplicate is such only if all the given cells contain the same data. These cells are A, B,C, D and E

    This is the code that I use to insert the data in the worksheet. As you can see I have tried using Countif and Countifs but with no success

    Please Login or Register  to view this content.
    Thank you for any help

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How can I avoid duplicates based on multiple cells with Userform VBA?

    Hello

    Use your Macro recorder to record yourself entering this array formula in a cell. Array Formulas are entered using Ctrl Shift Enter

    =MATCH("A|B|C|D",A:A & "|" & B:B & "|" & C:C & "|" & D:D,0)


    This is the macro code for cell E1

    Please Login or Register  to view this content.

    This returns the row number where

    Column A contains W
    Column B contains X
    Column C contains Y
    Column D contains Z

    So if E1 returns #N/A then you know that the entry WXYZ does not exist
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    11-09-2019
    Location
    Milan, Italy
    MS-Off Ver
    office 365
    Posts
    69

    Re: How can I avoid duplicates based on multiple cells with Userform VBA?

    Hello Mehemtcik, thank you for the prompt reply.

    I would like to use the formula in VBA, when I press the NewEntry button. How can I add that in the vba code?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Summing to Avoid Duplicates
    By andrewc in forum Excel General
    Replies: 3
    Last Post: 07-08-2019, 05:18 PM
  2. How do you avoid duplicates when using the randbetween function?
    By Monica in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-28-2014, 02:07 AM
  3. [SOLVED] Count without duplicates based on multiple criteria from different cells
    By perryadam in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-23-2013, 12:54 PM
  4. Code to prevent userform from saving duplicates based on 3 textboxes
    By Zygoid in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-28-2013, 11:04 AM
  5. Avoid duplicates
    By redja in forum Excel General
    Replies: 1
    Last Post: 02-22-2007, 07:43 PM
  6. Replies: 1
    Last Post: 05-22-2006, 04:01 PM
  7. how to avoid duplicates in excel workbook?
    By smart in forum Excel General
    Replies: 1
    Last Post: 01-10-2005, 11:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1