I'm struggling with the use of a string constant in an Excel formula.
I'm trying to get Last Row of a Excel range using Match Function.
Suppose we have the code below:
Const Range1 As String = "A1"
LastRow = sht.Range("A1").CurrentRegion.Rows.Count 'Works Ok
LastRow = sht.Range(Range1).CurrentRegion.Rows.Count 'Works Ok Too.
'The problem is with Match...
Const Range1 As String = "A:A"
LastRow = sht.[match(2,1/(A:A<>""))] 'Works Ok
LastRow = sht.[match(2,1/(Range1<>""))] 'Doesn't Work.
I think that method is the most efficient because it ignores empty cells and formulas without result (="").