Require macro

Ron99

Active Member
Joined
Feb 10, 2010
Messages
340
Office Version
  1. 2016
Platform
  1. Windows
Hello,
I need a macro to remove duplicates by row and also remove the blanks. Its a huge data by rows and columns
below example - duplicates "Rob & "goal" to be removed, but should retain unique and remove the blanks

gulfRobstatRobaimherofungoalviewreviewpagegoal

<tbody>
</tbody>


Output -


gulfRobstataimherofungoalviewreviewpage

<tbody>
</tbody>
 
Yes, That's correct. Row 4 to be copied to row 1 and then row 5 to be copied to row 4.
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
How about
Code:
Sub CopyDatatoOneRow()

   Dim Cl As Range

   With CreateObject("scripting.dictionary")
      For Each Cl In Range("A1", Cells(1, Columns.Count).End(xlToLeft))
         If Not .exists(Cl.Value) Then .Add Cl.Value, Nothing
      Next Cl
      For Each Cl In ActiveSheet.UsedRange.Offset(1).Resize(ActiveSheet.UsedRange.Rows.Count - 1)
         If .exists(Cl.Value) Then
            Cl.ClearContents
            Intersect(Cl.EntireRow, ActiveSheet.UsedRange).SpecialCells(xlConstants).Copy Cells(1, Columns.Count).End(xlToLeft).Offset(, 1)
            Cl.EntireRow.ClearContents
         End If
      Next Cl
      .removeall
   End With
   Columns(1).SpecialCells(xlBlanks).EntireRow.Delete
   With CreateObject("scripting.dictionary")
      For Each Cl In Range("A1").CurrentRegion.Offset(1)
         If Not Cl.Value = "" And Not .exists(Cl.Value) Then .Add Cl.Value, Nothing
      Next Cl
      Range("A2").Resize(, .Count).Value = .keys
      Rows("3:1048576").Delete
   End With
         
End Sub
 
Upvote 0
Hello,

I run the code and got the error message

Run time error - 438

Object doesn't support this property or method.
 
Upvote 0
Which line of code gave that error?
 
Upvote 0
Hello,

Error is on this line

Range("A2").Resize(, .Count).Value = .keys
 
Upvote 0
Hello,

Any help on this error message.

Thanks,
Ron
 
Upvote 0
Have you changed the code at all?
 
Upvote 0
I did try changing to - Sheets("Test1").Range("A2").Resize(, .Count).Value = .keys. which did not help. I have a very limited knowledge with Macro, if you can assist that will be a great help.

This code - Sub CopyDatatoOneRow() works absolutely fine for the 1st row in the database but doesn't proceed further for the remaining rows.

Thank you.
Ron
 
Upvote 0
Could you supply a sample of the data when it's failing? As I cannot replicate the error.
 
Upvote 0

Forum statistics

Threads
1,214,560
Messages
6,120,217
Members
448,951
Latest member
jennlynn

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top