View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Trent Argante Trent Argante is offline
external usenet poster
 
Posts: 39
Default Replace: Object Required

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?
--
Trent Argante
[DC.J(455)]