Question : VBScript Find and Replace text in Excel

I need help with a VBScript that would open a Excel spreadsheet and find and replace a specific string.

Answer : VBScript Find and Replace text in Excel

Try this...replaces all 'potato' with 'tomato'...
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
Const FromValue = "potato"
Const ToValue = "tomato"
 
Dim objExcel : Set objExcel = CreateObject("Excel.Application")
'objExcel.Visible = True
Set objWorkbook =  objExcel.Workbooks.Open("C:\Test.xls")
Dim objWorksheet : Set objWorksheet = objWorkbook.Worksheets(1)
'Dim objRange : Set objRange = objWorksheet.UsedRange
 
objWorksheet.Cells.Replace FromValue, ToValue
 
objExcel.DisplayAlerts = False 
objExcel.Save
objExcel.Quit
Open in New Window Select All
Random Solutions  
 
programming4us programming4us