I am trying to make a simple function that counts the number of pipelines listed in a sheet codenamed LINES. The range in the sheet LINES where the lines will be listed is $A$2:$A$1048576 and I have named the range "LineList". I have made a module containing all my global constants that are hardcoded, so that I can alter them easily in the future. The name of the LineList range is one of those, defined as such:
Public Const LINELIST_RNG As String = "LineList"
My function is the following. For some reason this command is failing, due to the LINELIST_RNG being empty:
Function numLines() As Integer
numLines = WorksheetFunction.CountA(LINES.Range(LINELIST_RNG))
End Function
However, if I hard-code the range name into this function, it works fine:
numLines = WorksheetFunction.CountA(LINES.Range("LineList"))
I am unsure why the .Range object cannot take LINELIST_RNG as an argument but will take "LineList".
as longmay be better as an integer overflows beyond +32767