I already have the code for replacing a string with a different string. It works when I know what the contents of the cell are. For example, in this case "A1" contains the string "test".
I am trying to figure out how to replace a string when I don't know the contents of the cell.
Code:
Sub Button1_Click()
Dim OriginalText As String
Dim CorrectedText As String
OriginalText = Range("A1").Value
CorrectedText = Replace(OriginalText, "test", "exam")
Range("A1").Value = CorrectedText
End Sub
I am trying to figure out how to replace a string when I don't know the contents of the cell.