First move the routine out of the user form to a standard code module.
Then remove the demonstration loop I used and place progress update within your existing loops.
'THIS SUB RUNS THE "RUN PROGRESS METER" BUTTON
Sub copyEquals()
' Progress Bar
Dim frmProgress As UserForm1
Dim lngIndex As Long
Dim sngPercent As Single
Dim lngMax As Long
Dim Sht1Rng As Range, Sht2Rng As Range
Dim Sht1Rng1 As Range, Sht2Rng1 As Range
Dim OuterCell As Range, InnerCell As Range, Cell As Range, OuterCell2 As Range
Set frmProgress = New UserForm1
Set Sht1Rng = Range("Sht1") 'Named range for small table
Set Sht1Rng1 = Range("Sht11") 'Named range for long table
Set Sht2Rng = Range("Sht2") 'Named range for xfer of small table data
Set Sht2Rng1 = Range("Sht21") 'Named range for xfer of long table data
Application.Cursor = xlWait
lngMax = Sht2Rng.Resize(, 1).Cells.Count + Sht2Rng1.Resize(, 1).Cells.Count
sngPercent = lngIndex / lngMax
frmProgress.ProgressStyle1 sngPercent, True
frmProgress.Show vbModeless
'------------------------
' Your code would go here
For Each OuterCell In Sht2Rng.Resize(, 1)
For Each InnerCell In Sht1Rng.Resize(, 1)
'If OuterCell.Value = InnerCell.Value Then
If InStr(1, OuterCell.Value, InnerCell.Value) Then
OuterCell.Offset(0, 1).Value = OuterCell.Offset(0, 1).Value + InnerCell.Offset(0, 1).Value
End If
Next
lngIndex = lngIndex + 1
sngPercent = lngIndex / lngMax
frmProgress.ProgressStyle1 sngPercent, True
DoEvents
Next
For Each OuterCell2 In Sht2Rng1.Resize(, 1)
For Each Cell In Sht1Rng1.Resize(, 1)
'If Right(OuterCell2.Value, ((Len(OuterCell2.Value) - 2) - _
InStr(OuterCell2.Value, "By"))) = Cell.Value Then
If InStr(1, OuterCell2.Value, Cell) Then
'MsgBox "OuterCell2.Value " & OuterCell2.Value
'MsgBox "Cell value " & cell.Value
OuterCell2.Offset(0, 1).Value = OuterCell2.Offset(0, 1).Value + Cell.Offset(0, 1).Value
End If
Next
lngIndex = lngIndex + 1
sngPercent = lngIndex / lngMax
frmProgress.ProgressStyle1 sngPercent, True
DoEvents
Next
Application.Cursor = xlDefault
Unload frmProgress
End Sub
Bookmarks