+ Reply to Thread
Results 1 to 4 of 4

Delete Duplicate Ranges in Excel

  1. #1
    Registered User
    Join Date
    04-23-2007
    Posts
    3

    Delete Duplicate Ranges in Excel

    I have thousands of questions & answers arranged in two consecutive columns as shown below. I want to delete all the duplicate Question and Answer sets keeping only one set. Sometimes questions may be same but answers differ as shown below. In this case I want to delete the colored/highlighted range.

    Question: xyz
    Correct Answer: abc
    Question: def
    Correct Answer: pqr
    Question: xyz
    Correct Answer: abc

    Question: xyz
    Correct Answer: asd

    How to write a macro for this?

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Krishna234,

    This macro will copy all unique questions and answers to a new worksheet named "Uniques". The macro assumes the questions and answers are on the ActiveSheet. You will need to change the range of the questions and answers to match what you are using. This example uses the range "A1:B1000". It's marked in red in the code. Copy this code and after inserting a Standard VBA Module into your Workbook, paste the code into it.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    04-23-2007
    Posts
    3

    RE: Delete Duplicate Ranges in Exce

    Hello Leith Ross,

    I tried the code. It indeed works as you have said, but the macro considers "Questions" and "Correct Answers" individually but not as a set. I mean each question has corresponding answer. The macro should treat set of questions and correct answers as a single entity. I am giving below the arrangements once again.

    BEFORE RUNNING MACRO:
    COLUMN A |COLUMN B
    Question | What is your pet's name
    Correct Answer | Doggy
    Question | What is your name?
    Correct Answer | Krishna
    Question | What is your pet's name
    Correct Answer | Doggy

    Question | What is your pet's name
    Correct Answer | Raaju
    Question | What is your pet's name
    Correct Answer | Raaju


    AFTER RUNNING MACRO
    COLUMN A |COLUMN B
    Question | What is your pet's name
    Correct Answer | Doggy
    Question | What is your name?
    Correct Answer | Krishna
    Question | What is your pet's name
    Correct Answer | Raaju

    COLUMN A acts as labels. Its contents are fixed: Content of first cell is "Question" and that of second cell is "Correct Answer" and are repeated.
    COLUMN B contains corresponding Question and answer: Content of first cell is for example "What is your pet's name" and that of second cell for example is "Doggy"

    Truly
    kRISHNA234
    Last edited by Krishna234; 04-24-2007 at 11:02 AM.

  4. #4
    Registered User
    Join Date
    04-23-2007
    Posts
    3
    I have written a code for the problem and I will be thankful to everyone who can find faults with it or suggests a better one.

    Please Login or Register  to view this content.
    Screen Shots before & after running the macro are attached (without macro) for your reference.

    Regards
    krishna
    Attached Images Attached Images

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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