Excel VBA Macro to Copy List but not Duplicate

Youseepooo

New Member
Joined
Feb 5, 2019
Messages
37
Hello,


I have a worksheet with many sheets that i would like to summarize into one sheet. Essentially i want to go through ranges $D$29:$D$39 and copy the list ( which includes a column of cells with texts & values ) however there are duplicates so i don't want the same cell value/text to appear twice on my summary sheet. I want it to do this for every sheet except 2 which are named "Ref" & "Summary" After going through every sheet's (excluding the 2 i mentioned) i would like it to paste all the values/text on the summary sheet in range
starting in column B31 of "Summary" sheet.

if it could paste it in alphabetical order that would be nice, but most importantly is to capture every different value/text (in all sheets excluding 2 sheets) for the summary sheet.

Thank You very much
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
How about
Code:
Sub Youseepooo()
   Dim Ws As Worksheet
   Dim Cl As Range
   
   With CreateObject("scripting.dictionary")
      .CompareMode = vbTextCompare
      For Each Ws In Worksheets
         If Ws.Name <> "Ref" And Ws.Name <> "Summary" Then
            For Each Cl In Ws.Range("D29:D39")
               .Item(Cl.Value) = Empty
            Next Cl
         End If
      Next Ws
      Sheets("Summary").Range("B31").Resize(.Count).Value = Application.Transpose(.Keys)
   End With
End Sub
 
Upvote 0
works good so far, it just seems to be picking up a null cell somewhere, is there a way to not make it display empty/null cells.
 
Upvote 0
Yup, like this
Code:
Sub Youseepooo()
   Dim Ws As Worksheet
   Dim Cl As Range
   
   With CreateObject("scripting.dictionary")
      .CompareMode = vbTextCompare
      For Each Ws In Worksheets
         If Ws.Name <> "Ref" And Ws.Name <> "Summary" Then
            For Each Cl In Ws.Range("D29:D39")
              [COLOR=#ff0000] If Cl.Value <> "" Then [/COLOR].Item(Cl.Value) = Empty
            Next Cl
         End If
      Next Ws
      Sheets("Summary").Range("B31").Resize(.Count).Value = Application.Transpose(.Keys)
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,186
Members
448,554
Latest member
Gleisner2

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