ninjalearner
New Member
i have written this code to code a function nameexists. I tried running it without success. Pls can the pro's help me look into it and make suggestions for ammendment.
Dim address As Range, name As String
Dim resp As String 'temp variable to hold input box variable; pass contents to address and name
Dim i As Integer
Set address = Range("A2:A14")
For i = 2 To 14
name = Range("address").Cells(i).Value
resp = InputBox("Enter Name Here", "Greetings")
Next
MsgBox "Does Name Exist? " & NameExists(address, name)
End Sub
Function NameExists(address As Range, name As String) As Boolean
Dim resp As String
Dim cell As Range
Dim i As Integer
NameExists = False
For Each cell In Range("address").Cells.Value
If name = resp Then
NameExists = True
End If
Next
End Function
Dim address As Range, name As String
Dim resp As String 'temp variable to hold input box variable; pass contents to address and name
Dim i As Integer
Set address = Range("A2:A14")
For i = 2 To 14
name = Range("address").Cells(i).Value
resp = InputBox("Enter Name Here", "Greetings")
Next
MsgBox "Does Name Exist? " & NameExists(address, name)
End Sub
Function NameExists(address As Range, name As String) As Boolean
Dim resp As String
Dim cell As Range
Dim i As Integer
NameExists = False
For Each cell In Range("address").Cells.Value
If name = resp Then
NameExists = True
End If
Next
End Function