+ Reply to Thread
Results 1 to 20 of 20

deleting lines

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690

    deleting lines

    hi guys

    i have a spreadsheet with approxiamtley 4982 lines on it
    column a is a date
    column b is a time

    now and again column a and column b have the same answer in them
    is there anyway i can highlight these as i only want one of the lines so that i can delete the other without having to scroll down them manually?

    regards
    steve

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi,

    See if this helps. I concatenated the time and date in Col C.

    Also this site shows you how to highlight duplicates

    http://www.cpearson.com/excel/duplic...tingDuplicates

    VBA Noob
    Attached Files Attached Files
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    thats of great help but of no real help noob
    although im grateful for your help i really dont understand formulas

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi stevesunfold,

    Just add the code to a module in your workbook then use this forumla in cell C2 and drag down

    =TEXT(A2,"dd/mm/yy")&" "&TEXT(B2,"HH:MM")

    module.

    Sub DeleteRows()
    Dim Last, Cnt As Long
    Dim Rng As Range
    Last = Cells(Rows.Count, "C").End(xlUp).Row
    Set Rng = Range("C2:C" & Last)
    For Cnt = Last To 1 Step -1
    If WorksheetFunction.CountIf(Rng, Cells(Cnt, "C").Value) > 1 Then
    Cells(Cnt, "C").EntireRow.Delete
    End If
    Next Cnt
    End Sub
    The code will run from the last cell in Col C to C2 deleting the entirerow as it goes.

    Non VBA would be use this in C2 and drag down

    =IF(MAX(COUNTIF(C2:C20,C2:C20))>1,"Duplicates","No Duplicates")
    Then filter on Duplicates and delete

    HTH

    VBA Noob

  5. #5
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    vba noob

    what can i say but youre a star

    many many thanks
    i did what you said and although i dont understand it it worked a treat

    thanks so much
    steve

  6. #6
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Glad it helped

    VBA Noob

+ 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