Compile error

G

George Gee

Hi all

I've received a worksheet from a colleague, when trying to run a macro,
I get a compile error - 'Cannot find project or library'

Code stops at --- hilltest = LCase(hilltest)

with LCase highlighted.

Can anyone explain the problem? Code below

---------------------------------------------------------------------------

Sub NameSearch(xtest)
Dim myName As String
Dim i As Integer, idb As Integer, myrow As Integer
Dim hilltest As String
'Dim xtest As Integer

idb = 3688

myName = Application.InputBox("Choose a Hill: You can use * as a
wildcard", Type:=2 + 4)

If myName = "False" Then
Exit Sub
End If

If myName = "" Then
Do While myName = ""
MsgBox ("You must enter a Hill Name")
myName = Application.InputBox("Choose a Hill: You can use * as a
wildcard", Type:=2 + 4)

If myName = "False" Then
Exit Sub
End If

Loop
End If

Sheets("Hills").Select
'MsgBox myName
For i = 2 To idb
Application.ScreenUpdating = False
ActiveSheet.Cells(i, 3).Select
hilltest = ActiveSheet.Cells(i, 3).Value
hilltest = LCase(hilltest)
myName = LCase(myName)

If hilltest Like myName Then
Application.ScreenUpdating = True
myrow = i
ActiveSheet.Rows(myrow).Select
xtest = MsgBox("Is this the Hill you want?", 3, "Search Result")

If xtest = 6 Then
Exit Sub
End If
If xtest = 2 Then
Exit Sub
End If
End If

'For i = 1 To 10
'On Error GoTo CheckFiles_Err
'ActiveSheet.Cells.Find(What:=myName, After:=ActiveCell, LookIn:=xlFormulas,
LookAt:=xlWhole, _
'SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:=False).Activate
'myName = InputBox("Choose a hill; * acts as a wild card, now Click
Cancel to make this selection or OK to continue looking for another hill",
"Hill Name", myName)
'If myName = "" Then
' Exit Sub
'End If
'Next i

'myName = True
'CheckFiles_Err: MsgBox "The Hill name you entered is not in the Database"

Next i

Sheets("Options").Select
MsgBox ("The Hill you entered is not in the Database")
End Sub

Many thanks
George Gee
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top