Isaac
Lifelong Learner
- Local time
- Today, 03:18
- Joined
- Mar 14, 2017
- Messages
- 8,778
Code:
Function ExistsInRCP(str1ID As String, str2Id As String) As Boolean
Dim ws As Worksheet, lastrow As Long, rng As Range
Set ws = ThisWorkbook.Worksheets("RCP")
lastrow = ws.Range("A" & ws.Rows.Count).End(xlUp).Row
ws.ListObjects("ListObjectName").Range.AutoFilter _
Field:=3, Criteria1:= _
str1ID & "_" & str2Id
Note how I get the lastrow in the sheet, a common method. (I've also seen some other methods, utilizing UsedRange or SpecialCells, but have been uncertain as to their advantages/disadvantages).
Let's say I execute that code and it applies a filter. Now, I want to find out whether "some rows" or "zero rows" were left, after applying the filter. It will be very possible when this function is called, that zero rows are returned.
What do you think is the BEST way to see if zero rows are returned? Just to use lastrow method again, and see if it goes all the way up to row 1?
Is there maybe another way I don't know that is better.
By the way, this is a table that was created by making and running a Data Connection to a Sharepoint list.