Hi all,
This code is from "Microsoft Excel 2019 VBA and Macros" book. I just have a query about how the function actually searches for the name in the workbook. Is the statement in bold within the if....then used to search for the FindName? How does this part determine a names existence?
Appreciate any help
Function NameExists(ByVal FindName As String, _
Optional TargetBook As Workbook) As Boolean
If TargetBook Is Nothing Then
If ActiveWorkbook Is Nothing Then
NameExists = False
Exit Function
End If
Set TargetBook = ActiveWorkbook
End If
On Error Resume Next
NameExists = CBool(Len(TargetBook.Names(FindName).Name) <> 0)
On Error GoTo 0
End Function
This code is from "Microsoft Excel 2019 VBA and Macros" book. I just have a query about how the function actually searches for the name in the workbook. Is the statement in bold within the if....then used to search for the FindName? How does this part determine a names existence?
Appreciate any help
Function NameExists(ByVal FindName As String, _
Optional TargetBook As Workbook) As Boolean
If TargetBook Is Nothing Then
If ActiveWorkbook Is Nothing Then
NameExists = False
Exit Function
End If
Set TargetBook = ActiveWorkbook
End If
On Error Resume Next
NameExists = CBool(Len(TargetBook.Names(FindName).Name) <> 0)
On Error GoTo 0
End Function