Unique items from different sheets

quej2003

New Member
Joined
Oct 5, 2010
Messages
49
Hi,

So I have a range of values that start and end in the same cells but over a few sheets (up to maybe 15/16). I had been using an udf to return to the unique values within each sheet, but wanted to create a timeline of that data so was looking to get the unique values over a couple of ranges over a few sheets, function I am using is below:

Code:
Function UniqueRecords(rng As Variant) As Variant()
' This udf filters unique distinct records (case sensitive)
Dim r As Single
Dim c As Single
Dim k As Single
Dim rt As Single
Dim ct As Single
Dim a As Single
Dim b As Single
Dim i As Single
Dim iCols As Single
Dim iRows As Single
Dim temp() As Variant
Dim j As Integer

rng = rng.Value
ReDim temp(UBound(rng, 2) - 1, 0)
For r = 1 To UBound(rng, 1)
  For rt = LBound(temp, 2) To UBound(temp, 2)
    For c = 1 To UBound(rng, 2)
      If temp(c - 1, rt) = rng(r, c) Then a = a + 1
    Next c
    If a = UBound(rng, 2) Then
      a = 0
      b = 0
      Exit For
    Else
      a = 0
      b = b + 1
    End If
  Next rt
  If b = UBound(temp, 2) + 1 Then
    For c = 1 To UBound(rng, 2)
      temp(c - 1, UBound(temp, 2)) = rng(r, c)
    Next c
    ReDim Preserve temp(UBound(temp, 1), UBound(temp, 2) + 1)
    b = 0
  End If
Next r
k = Range(Application.Caller.Address).Rows.Count
If Range(Application.Caller.Address).Columns.Count < UBound(rng, 2) Then
  MsgBox "There are more columns, extend user defined function to the right"
End If
If k < UBound(temp, 2) Then
Else
  For i = UBound(temp, 2) To k
    ReDim Preserve temp(UBound(temp, 1), i)
    For j = 0 To UBound(temp, 1)
      temp(j, i) = ""
    Next j
  Next i
End If
UniqueRecords = Application.Transpose(temp)
End Function
Was wondering if it is possible to do?

Thanks
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,224,584
Messages
6,179,693
Members
452,938
Latest member
babeneker

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