hello!
is there a macro to delete all duplicate rows?
is there a macro to delete all empty rows?
(seperate macros)
thanks!
hello!
is there a macro to delete all duplicate rows?
is there a macro to delete all empty rows?
(seperate macros)
thanks!
Hello...
Upload sample data...
Click *, if my suggestion helps you. Have a good day!!
Hi for empty rows You can use this:
![]()
Sub aa() Dim ost As Long Dim i As Long Dim z As Integer Application.ScreenUpdating = False ost = ActiveSheet.Cells.Find(what:="*", after:=Cells(1, 1), _ searchdirection:=xlPrevious).Row For i = ost To 1 Step -1 On Error Resume Next With ActiveSheet.Rows(i) z = .Find(what:="*", _ after:=.Parent.Cells(i, 1), _ searchdirection:=xlPrevious).Column If Err.Number <> 0 Then .Delete End With On Error GoTo 0 Next i Application.ScreenUpdating = True End Sub
Regards
tom1977
If You are satisfied with my solution click the small star icon on the left to say thanks.
Hi Tom,
Im happy to learn from you again and again. The above code of yours and your knowledge deserves a rep :-)
Thanks,
Bonny Tycoon
**If I was able to help please click the small star icon at the bottom left of my post **
For duplicate rows, are there just 2 rows duplicating or more?
If I have helped, Don't forget to add to my reputation (click on the star below the post)
Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
Use code tags when posting your VBA code: [code] Your code here [/code]
Based on what conditions should the duplicate rows be deleted? I mean, which are the fields that should be checked for duplicates?
Since you are attempting an universal solution, is there any particular range or can that be changing each time?
So even if a file has 20 columns of data, you want all 20 columns to be compared to each other for duplicates?
This is the code I usually use. It asks which column to check for duplicates and blanks.
Not the most efficient or best way at all but I personally like it. Good Luck![]()
Sub DeleteDuplicates() Dim colbox As String colbox = InputBox(Prompt:="Column to search for duplicates:", Title:="Column", Default:="A") colstring = colbox & ":" & colbox checkrow = 2 Application.ScreenUpdating = False Do Until checkrow = lastrow lastrow = ActiveSheet.UsedRange.Rows.Count matchcheck = Application.CountIf(Range(colstring), Cells(checkrow, colbox)) If matchcheck > 1 Then Cells(checkrow, colbox).EntireRow.Delete ElseIf Cells(checkrow, colbox) = "" Then Cells(checkrow, colbox).EntireRow.Delete Else checkrow = checkrow + 1 End If Loop Application.ScreenUpdating = True MsgBox ("Done deleting duplicates.") End Sub
![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks