Find and Replace Advanced

Advanced find and replace with multiple criteria and formatting options

132 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

Intermediate

Create Sheet Per Unique Value

Automatically create separate worksheets for each unique value in a column. Perfect for splitting...

View Template