Search and Find Missing In Action
On May 21, 1:03 pm, LarryP wrote:
The code is nothing fancy, just testing whether a certain filename exists
within a filepathname. (What I'm actually using it for is to confirm that a
user has saved a template file under another name; if not, it throws him
out.) Like this:
If Find("OriginalFile.xls", "c:\Documents And
Settings\Stuff\SavedAsFile.xls", 1) Then
MsgBox ("Naughty, naughty, same filename -- you'e outa here!")
End If
Compiling or running this, though, gives a Compile error: Sub or Function
not defined. Exact same if I use Search instead of Find.
"SixSigmaGuy" wrote:
It would help if you provided some source code so we could see what you are
doing.
I use "Find" quite a bit in my code.
Are you using it as a member of a range object? Are you setting a range
object to the return value?
The following code works for me. It finds a cell in column 2 that contains
the text "Six Sigma.":
Sub TestFind()
Dim r As Excel.Range
Set r = Worksheets("Sheet1").Columns(2).Find("Six Sigma", , xlValues,
xlPart)
End Sub
"LarryP" wrote in message
...
I'm trying to write VBA using either Search or Find to determine if string
A
exists in string B, and the debugger insists it doesn't recognize either,
although Help alleges they are available to VBA. Anyone have an idea why
the
error? No missing references.... (Excel 2003 SP3/Windows XP)
Hello LarryP,
Here is a function that takes the full file path and returns the file
name.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Function GetFileName(ByVal FullFilePath As String) As String
Dim FSO As Object
Dim FileName As String
FilePath = "C:\Documents and Settings\Owner\My Documents\Test
Document.xls"
Set FSO = CreateObject("Scripting.FileSystemObject")
GetFileName = FSO.GetFileName(FilePath)
Set FSO = Nothing
End Function
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sincerely,
Leith Ross
|