I guess you have just recorded the macro in Excel and invoking it from UiPath.
Please change the code into the following.
'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, _
For testing purpose, run the macro manually directly in Excel and check.
If it is running, the invoke it from UiPath.