+ Reply to Thread
Results 1 to 7 of 7

Excel vba to allow unique data only, in pair of two columns (without helping columns)

  1. #1
    Registered User
    Join Date
    07-23-2021
    Location
    Pakistan
    MS-Off Ver
    2019
    Posts
    10

    Question Excel vba to allow unique data only, in pair of two columns (without helping columns)

    hello all,

    I need some help to make a sheet which have a column of agent names and other for their working currencies, agents do work in multiple currencies. here i need to ensure data sets(Agent Name + Currency) be validated only once in the sheet. in case of duplicate set, it should revoke entry and popup a msg box.

    Moreover, for temp working i have tried to do it through helping column, but i need to replace it with some vba code. there are also some vlookups through that helping column, which also need to be replaced with vba code.

    looking for your kind help. attaching the working file in the post
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    08-15-2016
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    9

    Re: Excel vba to allow unique data only, in pair of two columns (without helping columns)

    try the attached, I've added another button called Remove Duplicates
    it calls a routine in Module1 to remove the duplicate agents

    you won't need the helper column (I've left there)
    also, I've created a copy of the AgentsInputs sheet just for comparison purposes
    Attached Files Attached Files

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,464

    Re: Excel vba to allow unique data only, in pair of two columns (without helping columns)

    Select A2:Bx, x would be any number of rows that you want.

    Apply data validation, formula =
    =COUNTIFS($A$2:$A2,$A2,$B$2:$B2,$B2)=1
    Last edited by jindon; 07-25-2021 at 10:51 PM.

  4. #4
    Registered User
    Join Date
    07-23-2021
    Location
    Pakistan
    MS-Off Ver
    2019
    Posts
    10

    Re: Excel vba to allow unique data only, in pair of two columns (without helping columns)

    Quote Originally Posted by jindon View Post
    Select A2:Bx, x would be any number of rows that you want.

    Apply data validation, formula =
    =COUNTIFS($A$2:$A2,$A2,$B$2:$B2,$B2)=1
    problem with data validation directly on excel is, when you ctrl+D or copy and paste some cells to another cells, it just replaces destination cell's data validation rules with the Source cell's data validation rules too. simply, it doesn't work with copy paste or ctrl+D.

    that would be great if we do the validation through vba.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,464

    Re: Excel vba to allow unique data only, in pair of two columns (without helping columns)

    I just posted the formula since you are applying data validation for yourself.
    To a worksheet code module
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    07-23-2021
    Location
    Pakistan
    MS-Off Ver
    2019
    Posts
    10

    Re: Excel vba to allow unique data only, in pair of two columns (without helping columns)

    it Worked perfect!!!
    Last edited by AliGW; 07-27-2021 at 10:39 AM. Reason: PLEASE don't quote unnecessarily!

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,369

    Re: Excel vba to allow unique data only, in pair of two columns (without helping columns)

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ 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. Replies: 7
    Last Post: 02-18-2021, 01:54 AM
  2. Scripting Dictionary to find unique pair of values from two different columns
    By sriley5 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-29-2020, 09:20 AM
  3. [SOLVED] Convert Single Pair of Columns to 3 Column (Pair) List
    By kencoburn in forum Excel General
    Replies: 7
    Last Post: 03-04-2017, 01:43 PM
  4. Replies: 5
    Last Post: 10-31-2016, 11:21 AM
  5. Duplicate rows, delete columns w/same data, combine columns w/unique data, Mac Excel 2011
    By msmcoin in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 2
    Last Post: 02-03-2013, 02:10 PM
  6. Replies: 3
    Last Post: 07-20-2012, 07:29 PM
  7. Getting rid of helping columns
    By paulgallanter in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-09-2006, 12:15 AM

Tags for this Thread

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