Consulting

Results 1 to 8 of 8

Thread: Sleeper: How to hilight duplicate ROWS in excel(plz read message)

  1. #1
    VBAX Regular
    Joined
    Sep 2005
    Posts
    78
    Location

    Sleeper: How to hilight duplicate ROWS in excel(plz read message)

    I have gone through the solution present in the forums.
    BUt they have checkin for the colums not for the entire row.
    I want my code to check the entire row for duplicate.
    my sheet dont have any column headings nothing.

    if 1st row contains
    hihellofruitswow!

    matching row should contain same data and both the rows should be highlighted.

    row will be a combination of cells(I hope u understand.)

  2. #2
    VBAX Mentor Justinlabenne's Avatar
    Joined
    Jul 2004
    Location
    Clyde, Ohio
    Posts
    408
    Location
    This will highlight all the rows where matches are found: Not sure if it exactly meets your specs but is it close?
    Justin Labenne

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by v_gyku
    I have gone through the solution present in the forums.
    BUt they have checkin for the colums not for the entire row.
    I want my code to check the entire row for duplicate.
    my sheet dont have any column headings nothing.

    if 1st row contains
    hihellofruitswow!

    matching row should contain same data and both the rows should be highlighted.

    row will be a combination of cells(I hope u understand.)
    You should lookup conditional formatting in the Help.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    VBAX Regular
    Joined
    Sep 2005
    Posts
    78
    Location
    Thank u sir...

    Sir ur code is checking for the words which will i type.
    But actually i am writing a vb script , on execution of which if two rows contains same data these rows should get highlighted.
    This code is doing if part of row is same. eg:-

    bob Lob Tob

    bob Lob Job


    then it should not highlight...
    only if all the data in row is matching then only it should highlight.

    I dont want any input box nothing

    On execution only it shoud check for same rows
    Exact same.

  5. #5
    VBAX Regular
    Joined
    Sep 2005
    Posts
    78
    Location
    I think we can do it in the following way:

    first take contents of cell A1
    check it with B1 then c1 then d1 ............
    if we found same contents then for the same row check second column
    then do same thing:
    check B1 with that found rows 2 column if it is also same proceed

    go on ..............

    If someone can help me out please.....

  6. #6
    VBAX Regular
    Joined
    Sep 2005
    Posts
    78
    Location
    I have tried this code but its not working.
    can u help me

    Dim highlight As Boolean
    Dim rng As Excel.Range
    Dim totrows As Integer
    Dim i As Integer
    Dim j As Integer
    Application.ScreenUpdating = False
    Set rng = objworksheet.UsedRange.Rows
    totrows = rng.Rows.Count
    'make sure the col to search on is highlighted
    For i = totrows To 1 Step -1
    myCheck = ActiveCell
    ActiveCell.Offset(1, 0).Select
    For j = 1 To i
    If ActiveCell = myCheck Then 'if two contents of two cells match
    Selection.Font.Bold = True ' change to bold
    Selection.Font.ColorIndex = 3 'change font to red
    highlight = True
    End If
    ActiveCell.Offset(1, 0).Select
    Next j
    ActiveCell.Offset(-i, 0).Select
    Next i
    Application.ScreenUpdating = True

  7. #7
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location
    attached is a little more than you want, but will solve your problem. The spreadsheet has a general purpose "dup finder" routine that highlights duplicate cells, columns or rows. There are also "higher level" routine that calls the dup finder routine for your special case, i.e., find all dup rows in the active sheet.

    NOTE: as presently written, cells with blanks are not handled in any special way for dup rows or dup columns (they are for dup cells). Thus all blank rows in the "working area" will be highlighted as "dups". The procedure is smart enough to ignore blank cols "to the right" and blank rows "at the bottom". The routines are not well documented (sorry).

    UPDATE: I tweaked the code so "NullsIgnored" works for all cases.
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

  8. #8
    Knowledge Base Approver VBAX Expert brettdj's Avatar
    Joined
    May 2004
    Location
    Melbourne
    Posts
    649
    Location

Posting Permissions

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