SearchAndReplaceCellContent

Description: Search for and replace content of cell(s).

Parameters:

SearchAndReplaceCellContent(sPathOriginal As String, sPathTarget As String, sSheet As String, sSearchFor As String, sReplaceWith As String, bCaseSensitive As Boolean, bLookAtPart As Boolean, bMatchByte As Boolean) As Long

Parameter

Meaning

sPathOriginal

Original Excel file

sPathTarget

Can be same as sPathOriginal, otherwise a new workbook is created.

sSheet

Name of the sheet to be searched

sSearchFor

Text to search for

sReplaceWith

Text to replace with

bCaseSensitive

TRUE means a case sensitive search

bLookAtPart

If TRUE, replacement will occur only if the sSearchFor comprises the entire cell content.

bMatchByte

May use ASCII or Unicode character sets. If bMatchByte is TRUE then replacement occurs only if both search and replace characters are in the same character set.

Return Values:

0: Success 

-3: Unable to create Excel Application. Is it installed? 

-4: Unable to destroy Excel Application. 

-200: Excel reported an error. 

-201: Shareware Expired. 

-208: Target Path folder does not exist, even after attempting to create it. 

-213: Invalid or missing sheet specified. 

Example Code: