Hello,
I have a large, 45 tab spreadsheet which the current code appears to be hanging, or at least is taking a very long time to run (even left overnight to no avail).
The spreadsheet consists of the first tab, Location_Summary (an 11,000 list of part numbers) with the subsequent tabs being area locations within a warehouse.
Each area location tab has part numbers listed in column A. Many part numbers are located in various areas.
On the Location_Summary tab, I am trying to return into column C (Sheet Names) the tab name/s where each part number shows up.Attached is a snip of the Location_Summary tab.
Hoping someone can offer advice how to improve the following code as it is not working, even when left as the only thing running over night.
Thank you in advance.
I have a large, 45 tab spreadsheet which the current code appears to be hanging, or at least is taking a very long time to run (even left overnight to no avail).
The spreadsheet consists of the first tab, Location_Summary (an 11,000 list of part numbers) with the subsequent tabs being area locations within a warehouse.
Each area location tab has part numbers listed in column A. Many part numbers are located in various areas.
On the Location_Summary tab, I am trying to return into column C (Sheet Names) the tab name/s where each part number shows up.Attached is a snip of the Location_Summary tab.
Hoping someone can offer advice how to improve the following code as it is not working, even when left as the only thing running over night.
Code:
Sub test()
Dim a, i As Long, ws As Worksheet, r As Range
With Sheets("Location_Summary").Cells(1).CurrentRegion
.Columns(3).Offset(1).ClearContents
a = .Value
For Each ws In Worksheets
If ws.Name <> "Location_Summary" Then
For i = 2 To UBound(a, 1)
Set r = ws.Columns(1).Find(a(i, 1), LookIn:=xlValues, lookat:=xlWhole)
If Not r Is Nothing Then
a(i, 3) = a(i, 3) & IIf(a(i, 3) <> "", ", ", "") & ws.Name
End If
Next
End If
Next
.Resize(, 3).Value = a
End With
End Sub
Last edited by a moderator: