View Single Post
 
Old 08-30-2021, 11:39 AM
Purfleet Purfleet is offline Windows 10 Office 2019
Expert
 
Join Date: Jun 2020
Location: Essex
Posts: 345
Purfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to behold
Default

To be honest i cant work out what you are trying to do, but if you want some kind of progress bar you can add a row count that shows on another sheet (this only show every 100 rows, but you can change that) - you will have to update your code so that the find and replace are working on the orginal sheet and not the 'Progress' sheet

Code:
Sub BulkReplace()
  Dim Rng As Range, SourceRng As Range, ReplaceRng As Range
  
  Dim rCount As Long   '<New
  Dim tCount As Long '<New
  Dim aSheet As String '<New
  
  aSheet = ActiveSheet.Name
    
  On Error Resume Next
  Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
  Set SourceRng = Application.InputBox("Source data:", "Bulk Replace", Application.Selection.Address, Type:=8)
  Err.Clear
 
  If Not SourceRng Is Nothing Then
    Set ReplaceRng = Application.InputBox("Replace range:", "Bulk Replace", Type:=8)
    Err.Clear
    If Not ReplaceRng Is Nothing Then
      
      Application.ScreenUpdating = False
        
        Worksheets.Add.Name = "Progress"
        tCount = Worksheets(aSheet).Cells(Rows.Count, 1).End(xlUp).Row '<New
        
            Worksheets(aSheet).Activate
        
        For Each Rng In ReplaceRng.Columns(1).Cell
          
                SourceRng.Replace what:=Rng.Value, replacement:=Rng.Offset(0, 1).Value
                rCount = rCount + 1
               
                If Int(rCount) / rCount = 1 Then '<New
                    Application.ScreenUpdating = False '<New
                        Worksheets("Progress").Range("a1") = rCount & "/" & tCount '<New
                        Worksheets("Progress").Activate '<New
                    Application.ScreenUpdating = True '<New
                End If '<New
                
        Next
       End If
  End If
  Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
Reply With Quote