Excel 2007. Relatively new to VBA and don't understand something. A workbook with Excel formulas is using data in another open workbook. Named ranges identifying this data were created in VBA. The named ranges work in these Excel formulas: AVERAGEIF(), MIN(), MAX(), COUNT() and COUNTA(), but do not work in COUNTIF(). An example named range is 5 rows x 1 column below.
Have tried creating the range names in two ways:
Dim LogRng As Range
Dim RangeName As String
RangeName = "RngRef"
'Method 1
Set LogRng = Workbooks(stLogFile_NO_PATH).Worksheets(stLogSheetName).Range("C4:C8")
ThisWorkbook.Names.Add Name:=RangeName, RefersTo:=LogRng
'Method 2
ThisWorkbook.Names.Add Name:=RangeName, RefersTo:=Workbooks(stLogFile_NO_PATH).Worksheets(stLogSheetName).Range("C4:C8")
Both methods correctly return the named range RngRef which is visible in Name Manager. What am I missing, and how can I return a named range for use in COUNTIF(), and likely COUNTIFS() as well?
PS ---
Don't want to use array formulas as have determined they slow things down. Making tens of thousands of calculations.
Have tried creating the range names in two ways:
Dim LogRng As Range
Dim RangeName As String
RangeName = "RngRef"
'Method 1
Set LogRng = Workbooks(stLogFile_NO_PATH).Worksheets(stLogSheetName).Range("C4:C8")
ThisWorkbook.Names.Add Name:=RangeName, RefersTo:=LogRng
'Method 2
ThisWorkbook.Names.Add Name:=RangeName, RefersTo:=Workbooks(stLogFile_NO_PATH).Worksheets(stLogSheetName).Range("C4:C8")
Both methods correctly return the named range RngRef which is visible in Name Manager. What am I missing, and how can I return a named range for use in COUNTIF(), and likely COUNTIFS() as well?
PS ---
Don't want to use array formulas as have determined they slow things down. Making tens of thousands of calculations.