Your technology certification is waiting. Enroll in Cloud Class ®
Const MACRO_NAME = "Search and Replace Subject"
Dim olkItem As Object, strFind As String, strReplace As String, intCount As Integer
strFind = InputBox("Enter the text to find", MACRO_NAME)
If strFind <> "" Then
strReplace = InputBox("Enter the text that will replace """ & strFind & """.", MACRO_NAME)
For Each olkItem In Application.ActiveExplorer.CurrentFolder.Items
If InStr(1, olkItem.Subject, strFind) Then
olkItem.Subject = Replace(olkItem.Subject, strFind, strReplace)
intCount = intCount + 1
Set olkItem = Nothing
msgbox "Find: " & strFind & vbCrLf _
& "Replace: " & strReplace & vbCrLf _
& "The macro found and replaced " & intCount & " instances.", vbInformation + vbOKOnly, MACRO_NAME
Open in new window
Your question, your audience. Choose who sees your identity—and your question—with question security.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.