title: vba find unique values of 3 different columns
body: <p>I am trying to find all different values from 3 different columns. The columns' row numbers and everything are different.</p>
  
  <p>Here below you can find my codes;</p>
  
  <pre><code>Set r1 = Worksheets(Ders_Sheet_Adi).Range("P22:P" &amp; LastRowXY_1 &amp; "")
  Set r2 = Worksheets(Ders_Sheet_Adi).Range("S22:S" &amp; LastRowXY_2 &amp; "")
  Set r3 = Worksheets(Ders_Sheet_Adi).Range("V22:V" &amp; LastRowXY_3 &amp; "")
  
  If LastRowXY_1 = 22 Then
      Worksheets(Ders_Sheet_Adi).Cells(22, 16).Copy
      Worksheets(Ders_Sheet_Adi).Range("AN1").PasteSpecial Paste:=xlPasteValues
  Else
      r1.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Worksheets(Ders_Sheet_Adi).Range("AN1")
  End If
  If LastRowXY_2 = 22 Then
      Worksheets(Ders_Sheet_Adi).Cells(22, 19).Copy
      Worksheets(Ders_Sheet_Adi).Range("AO1").PasteSpecial Paste:=xlPasteValues
  Else
      r2.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Worksheets(Ders_Sheet_Adi).Range("AO1")
  End If
  If LastRowXY_3 = 22 Then
      Worksheets(Ders_Sheet_Adi).Cells(22, 22).Copy
      Worksheets(Ders_Sheet_Adi).Range("AP1").PasteSpecial Paste:=xlPasteValues
  Else
      r3.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Worksheets(Ders_Sheet_Adi).Range("AP1")
  End If
  </code></pre>
  
  <p>As you can see what I am trying to do is simply get the unique values of the first range "r1" and put them at AN1, then do the same for r2 and r3. And then make a main column by putting that 3 output column in one main column, and use another advancedfilter on that column to create the final result.</p>
  
  <p>But unfortunately, when I do the debug with F8, I see that at output columns, there are duplicate values and that messes up the main output values.</p>