Summary of unique values from various sheets

Meesam

Board Regular
Joined
Nov 23, 2011
Messages
66
Dear All,
I have various sheets in a book with some material names / activities. I want a summary of UNIQUE material names giving their Totals (calculated from all the sheets). I have the following code but the problem is when I switch from one sheet to other and try to COMPARE the values, then I don't get the UNIQUE list. Maybe there is some problem with algorithm or something else.
Here is the code. Any help is appreciated.
<code>
For Each ws In wb.Worksheets
With ws
ws.Unprotect
If InStr(1, .Range("A1").Value, "DicoTech") > 0 Then
count = count + 1
valArea = ws.Range("B5").Value
Set locDesc = .Range("B7:B25").Find(What:="Description", LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows)
Set locTotal = .Range("B7:B35").Find(What:="Total", LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows)
startRow = locDesc.Row
endRow = locTotal.Row
Diff = (endRow - startRow) - 3
x = UBound(Mat_Name())
If count = 1 Then 'For first relevant sheet
For i = 1 To Diff
ReDim Preserve Mat_Name(i)
Mat_Name(i) = locDesc.Offset(i, 0).Value
Next i
Else 'For sheets after first relevant sheet
For i = 1 To Diff
y = i + x
ReDim Preserve Mat_Name(y)
For check = 1 To y 'Check for UNIQUE values
If Mat_Name(y) = Mat_Name(check) Then
Mat_Name(y) = locDesc.Offset(i, 0).Value
End If
Next
Next i
End If

Else
End If 'Criterion for sheet selection
End With
Next
</code>

Thanks in Advance.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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