+ Reply to Thread
Results 1 to 15 of 15

Data validation- Remove duplicate records by concatenating multiple columns to get unique

  1. #1
    Registered User
    Join Date
    08-04-2014
    Location
    Mysore
    MS-Off Ver
    2007
    Posts
    35

    Question Data validation- Remove duplicate records by concatenating multiple columns to get unique

    Hi,


    I am new for this forum, i want to know the Data validation in excel using macros.

    (1st method I know selecting Column A & B --DATA -->Remove Duplicates option-- will give me unique records)

    but i want to know how this can be achieve using macros...

    I attached the file which contains (originally 14900 records. But in this file only few records are given because i should know the functionality flow)
    Details of the file:
    flavour sheet -- flavour_id is the unique entity (primary key)
    season sheet -- season_id is the unique entity (primary key)
    price sheet -- flavour_id,season_id (both column A & B makes unique)


    after running macro
    1st it has to check whether flavour _id is there in flavour sheet
    2nd it has to check whether season _id is there in season sheet
    then in Price sheet it has to check for unique with 2 columns(i.e by making concatenate of Column A &B to obtain unique records)

    i should obtain an Output like
    unique_records -- new sheet
    duplicates -records in a new sheet..

    Please guide me how to resolve this data validation in Excel itself before importing data into an Database table( Sql server 2008 R2).
    So that Data has to Validated before saving/closing the Excel file.

    Please guide me how to resolve this using macro..


    Thank you.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Data validation- Remove duplicate records by concatenating multiple columns to get uni

    You can record yourself doing the duplicate check, and then inspect the code.
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Data validation- Remove duplicate records by concatenating multiple columns to get uni

    hi thara.p24, welcome to Excelforum, option, please check attachment, run code "test"(ALT+F11, select "test", click Run) or press Run button
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    08-04-2014
    Location
    Mysore
    MS-Off Ver
    2007
    Posts
    35

    Re: Data validation- Remove duplicate records by concatenating multiple columns to get uni

    Hi,

    Thank you so much....
    I expected the same result in which the flow has to taken place...
    this attachment is very helpful for me and learners also (if you would have been written comments(for main options) in the scripts then it will helped me a lot)
    please provide us a link or document/file so that we can learn (basic/fundamentals of) macros functionalists.
    How we should proceed with macros, advantages of macros etc. with examples and all..
    so that we can solve simple to complex algorithms in excel itself....(without entering in Database & (including triggering table) stage)

  5. #5
    Registered User
    Join Date
    08-04-2014
    Location
    Mysore
    MS-Off Ver
    2007
    Posts
    35

    Smile Re: Data validation- Remove duplicate records by concatenating multiple columns to get uni

    Hi,

    Thank you for the solution... it is working fine...
    Data can be validated in excel itself using macro functions!!!!!
    validating excel file before importing into Database (tables)with triggering action...
    (Database table containing composite primary key relationship/ foreign key constraints - by making unique records...)
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Data validation- Remove duplicate records by concatenating multiple columns to get uni

    commented code:

    Please Login or Register  to view this content.
    Helpful information and links: http://www.excelforum.com/excel-prog...materials.html

  7. #7
    Registered User
    Join Date
    08-04-2014
    Location
    Mysore
    MS-Off Ver
    2007
    Posts
    35

    Question Re: Data validation- Remove duplicate records by concatenating multiple columns to get uni

    Hi,

    Thank you for providing the comments and links..

    This is the syntax for declaration of data types....
    Dim price_sh_lrow As Long, flavour_sh_lrow As Long, season_sh_lrow As Long, flavour_str As String, season_str As String, uncheck As String

    I am facing one issue that when i execute the same procedure with original data..

    All text column will be treating as number format in output sheets...(few data having an Flavour_id (text/nvarchar) starts from "00" it is eliminating 00 character...)
    I should retain the original data flow only...
    (Formatting cell --Text Column A & B should be text only in output files- unique_records/duplicates)

    I am enclosed the file. please refer...

    plz suggest me how to ensure this.. and get proper original data in output sheets...(unique_records/duplicate)
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Data validation- Remove duplicate records by concatenating multiple columns to get uni

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    08-04-2014
    Location
    Mysore
    MS-Off Ver
    2007
    Posts
    35

    Question Re: Data validation- Remove duplicate records by concatenating multiple columns to get uni

    Hi,

    Thank for the data type conversion...
    i am having two particular cases
    such that only one excel sheet will contains data, we need to check data validation (using macros).. with multiple column(A,B,C) will make unique. (output should be unique_records & duplicates)
    other scenario w.r.t Date and time specific... with multiple column(A,B) will make unique. (output should be unique_records & duplicates)


    Can we make use same script for this issues.. or any other method/macro is available to check the concatenate function using macro
    Attached Files Attached Files
    Last edited by thara.p24; 08-06-2014 at 08:02 AM.

  10. #10
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Data validation- Remove duplicate records by concatenating multiple columns to get uni

    please post a sample file and result expected

  11. #11
    Registered User
    Join Date
    08-04-2014
    Location
    Mysore
    MS-Off Ver
    2007
    Posts
    35

    Question Re: Data validation- Remove duplicate records by concatenating multiple columns to get uni

    Hi,
    I enclosed the Result sheet also for reference...
    please refer....
    Attached Files Attached Files

  12. #12
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Data validation- Remove duplicate records by concatenating multiple columns to get uni

    please check attachment
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    08-04-2014
    Location
    Mysore
    MS-Off Ver
    2007
    Posts
    35

    Exclamation Re: Data validation- Remove duplicate records by concatenating multiple columns to get uni

    Thank you...

    I want to know the security options...
    whether this query i suppose to post in new thread?????

    Suppose we given this template to 1 end user to entry only raw_data sheet..(he should have all permission for that sheet)
    He should have an read only access for customer, season,flavour sheet.. such that, the person need not insert/delete/update any records for those sheets..
    & also he should not see the macro function.. (so that macro will be secured)
    he just have to execute run button...
    then he should get output as unique_records & duplicates sheets...

    and then unique_records should be readable.. he is not suppose to entry/alter any data in that sheet..

    But the developer who is developing that template of that excel with macro should have all access/permission.

    I enclosed this file. please refer
    Please suggest me about the security issues.....
    Attached Files Attached Files

  14. #14
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Data validation- Remove duplicate records by concatenating multiple columns to get uni

    I would suggest this issue to be posted as a separate thread as it does not relate to the original thread topic

  15. #15
    Registered User
    Join Date
    08-04-2014
    Location
    Mysore
    MS-Off Ver
    2007
    Posts
    35

    Re: Data validation- Remove duplicate records by concatenating multiple columns to get uni

    Hi,
    ok ...
    Thank you...

+ 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] VBA: Pull unique text records from multiple columns and store into array?
    By kaptenstofil in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-24-2014, 10:39 AM
  2. [SOLVED] Append Data in Excel and remove duplicate records - Macro
    By socrates1911 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-20-2013, 06:01 PM
  3. How to merge duplicates while concatenating unique data from 3 columns
    By mdhillyer in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-11-2012, 01:13 AM
  4. Macro validation for duplicate and uniqie records with their data being pulled
    By preciousmetal2004 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-20-2012, 05:15 PM
  5. Replies: 7
    Last Post: 07-13-2009, 01:30 PM

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