I guess you have just recorded the macro in Excel and invoking it from UiPath.
Please change the code into the following.
Sub ReplaceText()
'sheet1 is the sheet name you are going to replace
'A:Z is the range the data will be replaced
sheet1.Range("A:Z").Replace What:=" – ", Replacement:=" - ", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub
For testing purpose, run the macro manually directly in Excel and check.
If it is running, the invoke it from UiPath.