Data Processing & Cleanup Intermediate

Find and Replace Advanced

Advanced find and replace with multiple criteria and formatting options

14 views

Perfect For:

  • Bulk text replacement
  • Format standardisation
  • Data correction
VBA Code
Sub AdvancedFindReplace()
    Dim ws As Worksheet
    Dim findText As String, replaceText As String
    Dim replaceCount As Long

    Set ws = ActiveSheet

    findText = InputBox("Enter text to find:")
    If findText = "" Then Exit Sub

    replaceText = InputBox("Enter replacement text:")

    ' Perform find and replace with options
    With ws.UsedRange
        replaceCount = 0
        For Each cell In .Cells
            If InStr(cell.Value, findText) > 0 Then
                cell.Value = Replace(cell.Value, findText, replaceText)
                replaceCount = replaceCount + 1
            End If
        Next cell
    End With

    MsgBox "Replaced " & replaceCount & " occurrences of \"" & findText & "\""
End Sub

Related Topics

find replace text formatting

Need Custom VBA Solutions?

Our AI-powered VBA generator can create custom code tailored to your specific requirements in seconds.

Generate Custom VBA Code

Related Templates

More VBA templates in the same category

Beginner

Data Processing & Cleanup

Remove duplicates, clean data formats, and standardise entries

View Template