CONCAT or INDIRECT not working for dynamic formula

bwinchell

New Member
Joined
Jul 19, 2016
Messages
15
Hello,
I have used the INDIRECT in a bunch of workbooks to dynamically create formulas based on 1 or multiple cells. Usually to reference a worksheet tab name based on date or function.

A3 = 10012015 (cell formatted as text as I need leading zeros)

E.g.
Code:
=COUNTIFS(INDIRECT("VM_Audit_"&$A3&"!"&"$A$2:$A$2000"),"<>"&"",INDIRECT("VM_Audit_"&$A3&"!"&"$I$2:$I$2000"),"BC_ESXi_CLUST*")
This will translate into and work fine
Code:
=COUNTIFS(VM_Audit_10012015!$A$2:$A$2000,"<>",VM_Audit_10012015!$I$2:$I$2000,"BC_ESXi_CLUST*")

I am trying to do something very similar to count distinctive occurrences of text. I have tried the CONCAT & INDIRECT in this formula but neither will work. It logically makes sense but something is breaking.

Static formula that works
Code:
{=SUM(IF(VM_Audit_10012015!$J2:$J2000<>"",1/COUNTIF(VM_Audit_10012015!$J2:$J2000,VM_Audit_10012015!$J2:$J2000),0))}
Dynamic formula that does not work. Returns a #VALUE error:
Code:
{=SUM(IF((CONCATENATE("'VM_Audit_",$A3,"'!","$J2:$J2000","<>","""")),1/COUNTIF(VM_Audit_10012015!$J2:$J2000,VM_Audit_10012015!$J2:$J2000),0))}
Dynamic formula that does not work. Returns a #REF error:
Code:
{=SUM(IF(INDIRECT("VM_Audit_"&$A3&"!"&"$J$2:$J$2000"&"<>"&""""),1/COUNTIF(VM_Audit_10012015!$J2:$J2000,VM_Audit_10012015!$J2:$J2000),0))}

Any suggestions or assistance? I am stuck on this one and cannot figure out why this not working.


PS
Is there any way to copy the text out of the "evaluate formula" window? It is too small and I cannot see exactly how many commas are being entered.

PSS
If there are any Excel developers looking at this, please make the window re-sizable or simple copy/paste functionality

Thanks
B
 

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,003
Try...

Code:
=SUM(IF(INDIRECT("'VM_Audit_"&$A3&"'!$J2:$J2000")<>"",1/COUNTIF(INDIRECT("'VM_Audit_"&$A3&"'!$J2:$J2000"),INDIRECT("'VM_Audit_"&$A3&"'!$J2:$J2000"))))
...confirmed with CONTROL+SHIFT+ENTER.

Hope this helps!
 
Last edited:

bwinchell

New Member
Joined
Jul 19, 2016
Messages
15
Try...

Code:
=SUM(IF(INDIRECT("'VM_Audit_"&$A3&"'!$J2:$J2000")<>"",1/COUNTIF(INDIRECT("'VM_Audit_"&$A3&"'!$J2:$J2000"),INDIRECT("'VM_Audit_"&$A3&"'!$J2:$J2000"))))
...confirmed with CONTROL+SHIFT+ENTER.

Hope this helps!

That worked.
Thanks
B
 

Forum statistics

Threads
1,081,702
Messages
5,360,743
Members
400,595
Latest member
T_Dubs

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top