G
Guest
Here' my code:
Dim varSht As Variant
Dim FoundCell As Range
' Iterates through sheets, finds data, & replaces data
For Each varSht In Workbooks(sFilename).Sheets
' Use Excel's Internal Find & Replace Method
Set FoundCell = varSht.Cells.Replace(What:=sFindWhat, _
Replacement:=sReplaceWith, _
LookAt:=vLookAt, MatchCase:=bMatchCase)
If Not FoundCell Is Nothing Then
fncStdFind = True
Exit Function
End If
Next
When I run this, the 'Set FoundCell = varSht.Cells.Replace' line is
highlighted, and the error 'Object required.' is displayed.
If I change 'Dim varSht As Variant' to 'Dim varSht As WorkSheet', then it
gives me a 'Type mismatch' error with the same line highlighted.
What the heck?
Dim varSht As Variant
Dim FoundCell As Range
' Iterates through sheets, finds data, & replaces data
For Each varSht In Workbooks(sFilename).Sheets
' Use Excel's Internal Find & Replace Method
Set FoundCell = varSht.Cells.Replace(What:=sFindWhat, _
Replacement:=sReplaceWith, _
LookAt:=vLookAt, MatchCase:=bMatchCase)
If Not FoundCell Is Nothing Then
fncStdFind = True
Exit Function
End If
Next
When I run this, the 'Set FoundCell = varSht.Cells.Replace' line is
highlighted, and the error 'Object required.' is displayed.
If I change 'Dim varSht As Variant' to 'Dim varSht As WorkSheet', then it
gives me a 'Type mismatch' error with the same line highlighted.
What the heck?