Kentucky_User
New Member
- Joined
- Feb 11, 2015
- Messages
- 3
I'd appreciate any insight from someone experience with writing VBA functions.
I am trying to write a function that returns a Boolean value. The function has two arguments, a Range argument and string argument. The function is supposed to take the value of a string and search a range for the value. If the function finds the string value, the function is true. If not, it is false.
The function is embedded in a worksheet with a cell that returns the value of the Boolean variable. The function is written in the cell as such: FunctionName(E:4, B1:B13).
The problem I am having is that nothing is returned into the cell where the function is written. The variable "name" is linked to cell E:4 and the variable "address" is linked to range B1:B13. Here is my VBA code:
Function NameExists(name As String, address As Range) As Boolean
Dim cell As Range
NameExists = False
With Worksheets("Sheet1").Range("address")
If Range("address").Text = Range("name").Text Then
NameExists = True
Else
NameExists = False
End If
End With
End Function
I am trying to write a function that returns a Boolean value. The function has two arguments, a Range argument and string argument. The function is supposed to take the value of a string and search a range for the value. If the function finds the string value, the function is true. If not, it is false.
The function is embedded in a worksheet with a cell that returns the value of the Boolean variable. The function is written in the cell as such: FunctionName(E:4, B1:B13).
The problem I am having is that nothing is returned into the cell where the function is written. The variable "name" is linked to cell E:4 and the variable "address" is linked to range B1:B13. Here is my VBA code:
Function NameExists(name As String, address As Range) As Boolean
Dim cell As Range
NameExists = False
With Worksheets("Sheet1").Range("address")
If Range("address").Text = Range("name").Text Then
NameExists = True
Else
NameExists = False
End If
End With
End Function