Using Name Range in COUNTIF()

toliphint

New Member
Joined
Aug 24, 2015
Messages
18
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.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Did you read this?
Yes I did read it, but my question does not apply to the points raised in that post.
- My range is contiguous
- My range name does not have a "dot" in it
- I tried an array CSE formula and does not work
- I'm not trying to add 2 counts

Just trying to understand why the returned range name does not work in COUNTIF() but does work in other functions.
Anyone please?
 
Upvote 0
Are you trying for relative range? or absolute? How are you attempting to use them within a formula?
 
Upvote 0
Here it works for me just fine:

With Named Range: RngRef ='MrExcel Help - toliphint'!$C$4:$C$8

Book1
CDE
410
541
681
770
821
MrExcel Help - toliphint
Cell Formulas
RangeFormula
E4E4=COUNTIFS(RngRef,"="&(2*INT(RngRef/2)))
 
Upvote 0
Yes it does! And apologies for this post. I cannot explain why, but last night I exited Excel and reloaded and it worked as it should.
 
Upvote 0

Forum statistics

Threads
1,215,025
Messages
6,122,734
Members
449,094
Latest member
dsharae57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top