+ Reply to Thread
Results 1 to 10 of 10

Macro to delete duplicate cell only not entire row if some data is duplicated in colunm

  1. #1
    Registered User
    Join Date
    05-27-2014
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    57

    Red face Macro to delete duplicate cell only not entire row if some data is duplicated in colunm

    Hi Thanks for your help in advance....
    here's what I am trying to do


    the data is like that
    ID Name Course Session Grade unit
    21 Fraser BB 1 7 Math
    21 Fraser BB 1 7 accounting
    22 Debel BB 1 7 Math
    22 Debel BB 1 7 Chemistry

    I want

    ID Name Course Session Grade unit
    21 Fraser BB 1 7 Math
    accounting
    22 Debel BB 1 7 Math
    Chemistry

    It means running a macro to delete the duplicated data in the colunm that I will select only but not delete the row ...
    a bit lost Thanks for any help

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Macro to delete duplicate cell only not entire row if some data is duplicated in colun

    Here you go. Not the most efficient, but it works.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by daffodil11; 05-27-2014 at 08:52 PM. Reason: added example
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  3. #3
    Registered User
    Join Date
    05-27-2014
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    57

    Re: Macro to delete duplicate cell only not entire row if some data is duplicated in colun

    data.xlsxhow it should be.xlsxdata.xlsxhow it should be.xlsxthank you so Much daffodil11 !!!
    Ok Can I ask one more favour....
    I want to edit the macro as I actually have
    From A to I included will be duplicated info name student id.... but
    Data in JKLMN will need to stay where they are and not be moved to A underneath... do not know If I am clear

    I am uploading the data and how I want it ... it will be better!!!!

  4. #4
    Registered User
    Join Date
    05-27-2014
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    57

    Re: Macro to delete duplicate cell only not entire row if some data is duplicated in colun

    I sort of modified the code and it gives me sort of what I want but some students may be enrolled in more than 2 units so more than two rows sometimes 3 sometimes 4 I cannot see where the code can be modified it only works when a student has two units if more than 2 his name comes again as a separate row with all the data... Thank you

    Sub Platypi()

    Dim c As Range
    Dim cRang As Range

    Set cRang = Range("A2", Range("A" & Rows.Count).End(xlUp))

    For Each c In cRang

    If c = c.Offset(-1, 0) Then

    If c.Offset(0, 1) = c.Offset(-1, 1) Then

    If c.Offset(0, 2) = c.Offset(-1, 2) Then

    If c.Offset(0, 3) = c.Offset(-1, 3) Then

    If c.Offset(0, 4) = c.Offset(-1, 4) Then


    Range(c.Offset(0, 0), c.Offset(0, 8)).ClearContents

    End If

    End If

    End If

    End If

    End If

    Next c

    End Sub

  5. #5
    Registered User
    Join Date
    05-27-2014
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    57

    Re: Macro to delete duplicate cell only not entire row if some data is duplicated in colun

    A big thank you to whoever can help me as I spent all day trying to modify the vba... and I am dumb as when it come to that

  6. #6
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Macro to delete duplicate cell only not entire row if some data is duplicated in colun

    I'm pretty VB dumb too, I just have a lot of practice of being dumb at it. I'll give it a shot.

    For something like this with multiple repeats, it would probably be best if we cycled from the bottom up, instead of top down.

  7. #7
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: Macro to delete duplicate cell only not entire row if some data is duplicated in colun

    Hi Petitesouris

    This below code will do this:
    - Loop through all rows (starting at 1)
    - Checks if value in col 1 is in a temporary Array
    - If False, it will add the value to the Array. If True, it will clear the contents of cols 1 to 9


    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    05-27-2014
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    57

    Re: Macro to delete duplicate cell only not entire row if some data is duplicated in colun

    Thank you so much for that Rkey it did work like a charm!!!!! I do not know how to thank you enough....

  9. #9
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: Macro to delete duplicate cell only not entire row if some data is duplicated in colun

    Hi petitesouris.

    Your welcome, good luck with it.
    Don't forget to Mark your tread as solved btw, makes it easier to search for it for other users.

    Best regards,
    Rick

  10. #10
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Macro to delete duplicate cell only not entire row if some data is duplicated in colun

    If you just want appearance, you could put Conditional Formatting on A1 with the condition
    =MATCH($A1,$A:$A,0)<>ROW($A1)

    to make the Font color white and then copy it to all cells of columns A:E
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. 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. Replies: 5
    Last Post: 02-24-2015, 01:22 PM
  2. [SOLVED] How to delete the ENTIRE row if only one cell is duplicated?
    By sami770 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-15-2014, 02:18 PM
  3. Replies: 4
    Last Post: 09-12-2013, 03:01 AM
  4. macro to delete entire row of duplicate dates and times dd/mm/yyyy hh:mm:ss
    By bradyj2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-02-2011, 05:41 AM
  5. Macro Help - Delete Duplicated Data
    By mccrimmon in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-02-2005, 09:05 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