COUNTIF from another file

Schturman

Board Regular
Joined
May 28, 2022
Messages
63
Office Version
  1. 2019
Platform
  1. Windows
Hi to all
I need to count one name from another file. The name can appear in 3 diff variations, for example:
Nati
Nati*
Nati**


The name for search is always clean (without * or **), for example in cell CP27 you can see name Nati

I used command:
Code:
=COUNTIF('[filename.xlsm]sheet_name'!$D$7:$I$55,CP27&"*")
and it working perfectly and count for me all 3 variation, but when I close the source file, the result shown as #VALUE (yes already know that excel can't show result when source file is closed :) )

I started to use this format for count (from this post):
Code:
=COUNT(IF('[filename.xlsm]sheet_name'!$D$7:$I$55=CP27,1)

It working, but problem is - it count only clean name, that mean only Nati, and I need use it like this to count all 3 variations:
Code:
=COUNT(IF('[filename.xlsm]sheet_name'!$D$7:$I$55=CP27,1),IF('[filename.xlsm]sheet_name'!$D$7:$I$55=CP27&"*",1),IF('[filename.xlsm]sheet_name'!$D$7:$I$55=CP27&"**",1))

Same with SUMPRODUCT formula...
Can I shorten this formula somehow and it will count all 3 variations ?
Thanks
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Can you try if this formula works?
=COUNTIF('[filename.xlsm]sheet_name'!$D$7:$I$55,CP27)+COUNTIF('[filename.xlsm]sheet_name'!$D$7:$I$55,CP27&"~*")+COUNTIF('[filename.xlsm]sheet_name'!$D$7:$I$55,CP27&"~*~*")
 
Upvote 0
One thing I found when referencing another file - when you create the formula and both files are open (of course!), the reference will appear as noted by @Rows N Columns . However, when you close the file referenced, the entire path will be added to the formula. At that point the referenced file does not (shouldn't!) have to be opened for the formula to work.
So COUNTIF('[filename.xlsm]sheet_name'!$D$7:$I$55,CP27) would become COUNTIF('C:\Users\USERID\Desktop\[filename.xlsm]sheet_name'!$D$7:$I$55,CP27).
 
Upvote 0
Countifs does not work with closed files, so you need to use sumproduct
Excel Formula:
=SUMPRODUCT(--(LEFT([filename.xlsm]sheet_name!$D$7:$I$55,LEN(CP27))=CP27))
 
Upvote 1
Solution
Countifs does not work with closed files, so you need to use sumproduct
Excel Formula:
=SUMPRODUCT(--(LEFT([filename.xlsm]sheet_name!$D$7:$I$55,LEN(CP27))=CP27))
I stand corrected! I just tried it with SUMPRODUCT and it didn't work there either 😟. At the time (long before I even knew what Power Query was!) I was using VLOOKUP (no XLOOKUP back then), and both files were in the same local folder. I tried it before posting and it SEEMED to work, but now it doesn't appear to work at all. Well, there's always Power Query!
 
Upvote 0
Sumproduct does work with closed workbooks.
 
Upvote 0
I just tried it with SUMPRODUCT and it didn't work there either
SUMPRODUCT does work with closed files, so whatever you tried, the issue wasn't with SUMPRODUCT itself.
 
Upvote 0
Can you try if this formula works?
=COUNTIF('[filename.xlsm]sheet_name'!$D$7:$I$55,CP27)+COUNTIF('[filename.xlsm]sheet_name'!$D$7:$I$55,CP27&"~*")+COUNTIF('[filename.xlsm]sheet_name'!$D$7:$I$55,CP27&"~*~*")
COUNTIF not work if source file is closed.

One thing I found when referencing another file - when you create the formula and both files are open (of course!), the reference will appear as noted by @Rows N Columns . However, when you close the file referenced, the entire path will be added to the formula. At that point the referenced file does not (shouldn't!) have to be opened for the formula to work.
So COUNTIF('[filename.xlsm]sheet_name'!$D$7:$I$55,CP27) would become COUNTIF('C:\Users\USERID\Desktop\[filename.xlsm]sheet_name'!$D$7:$I$55,CP27).
COUNTIF not work if source file is closed, I wrote it in my post.

Countifs does not work with closed files, so you need to use sumproduct
Excel Formula:
=SUMPRODUCT(--(LEFT([filename.xlsm]sheet_name!$D$7:$I$55,LEN(CP27))=CP27))
This formula working perfectly !!! Thank you very much !
I tried it without LEFT and LEN, this is a reason it not worked for me.
Thanks again!
 
Upvote 0
By the way, I checked the same way with COUNT formula with LEFT and LEN:
Excel Formula:
=COUNT(IF(LEFT('[filename.xlsm]Sheet_name'!$D$7:$I$55,LEN(A4))=A4,1))
And it also working perfectly :biggrin: Count and show result also if source file is closed ;)
@Fluff , thanks again for idea !
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,930
Members
452,367
Latest member
TePunaBloke

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