find if `find` method returns `nothing` in excel vba
问题 I'm trying to find an id in a list and get it's address, but also deal with a situation if nothing is found. Here's what I have: Function find_in_two_ranges_two_sheets(ws1 As String, col1 As Integer) As Range Dim rows1 As Integer rows1 = Get_Rows_Generic(ws1, 1) Dim range1 As Range ' range of first search With Worksheets(ws1) Set range1 = .Range(.Cells(1, col1), .Cells(rows1, col1)) End With Dim found1 As Range Set found1 = range1.Find("test id", LookIn:=xlValues) If found1 = Nothing Then