Excel Indirect command returns #value - excel-indirect

Using COUNTIF to count the number of times the value "HW or SW" shows up in a column. I am not sure how many rows of data I will end up with so I want to make that a variable, using INDIRECT. This formula returns a #VALUE error and I cannot figure out why: =COUNTIF('Daily_Data_Dump'!$G$2:INDIRECT("$G"&AB3),"HW_or_SW") Where the value in cell "AB3" is 5000. In my mind is should be the equivalent of =COUNTIF('Daily_Data_Dump'!$G$2:$G5000,"HW_or_SW"). Thanks for any help.

"In my mind is should be the equivalent of =COUNTIF('Daily_Data_Dump'!$G$2:$G5000,"HW_or_SW")."
That is correct, the problem is something else. The adress is wrong, try:
=COUNTIF('Daily_Data_Dump'!$G$2:INDIRECT("Daily_Data_Dump!$G"&AB3),"HW_or_SW")

Related

Excel VBA Evaluate not working, getting a #VALUE error

I have a VBA formula that works when I use the ActiveCell.Formula2R1C1 function, which I used to test that I could get the result I want. This works as it should, giving me a comma delimited list.
ActiveCell.Formula2R1C1 = "=SUBSTITUTE(ARRAYTOTEXT(FILTER(VendSelect1,VendSelect3=LEFT(R[-7]C[-3],6))),LEFT(R[-7]C[-3],6) & "","","""")"
VendSelect1 and VendSelect3 are named ranges from a table in another tab
I am wanting to use the result of this formula as a string to use in a Data Validation list. The reason to go this route is the list will be dynamic based on a value that is entered in another cell, so the list will vary. I have the code for creating the Data Validation working, I just need to get the result of the above equation to be stored as a variable for that code.
I have tried using the Evaluate function to store the result but when I try to put that value in a cell to test that it is working, I get a #VALUE error in the cell. Is this just more complicated a formula than Evaluate can handle? Or am I doing something wrong? I am open to other suggestions to accomplish the same thing but I'm not a VBA expert and this has been the best thing I have found, so far, to accomplish this. Here is the code I have that is giving me the #VALUE error in cell D14.
Sub Test()
Dim FormTest As Variant
FormTest = Evaluate("=FILTER(VendSelect1,VendSelect3=LEFT(R[-7]C[-3],6))")
Range("D14") = FormTest
End Sub
I've been trying to get this to work for about 2 days and this seems to be the last obstacle to getting what I am wanting to do.
Thank you, in advance.

INDIRECT If Statments keeps giving #REF

I'm trying to change an if statement to an indirect one as the current one that works keeps changing from C27 to #REF! when I delete Row 27 in the Tracker sheet.
=IF('Tracker Sheet'!C27="","",'Tracker Sheet'!C27)
This is the old if statement that works
=IF(INDIRECT('Tracker Sheet'!C27)="","",INDIRECT('Tracker Sheet'!C27))
This is the if statement that I try to convert but gives me #REF!
Any help would be greatly appreciated
Use index:
=IF(INDEX('Tracker Sheet'!C:C,27)="","",INDEX('Tracker Sheet'!C:C,27))
As long as you use the cell address directly when it is deleted it will return #REF as you are deleting the reference.
This will always look at what is the current 27th row in column C.

VBA Alternative for sumproduct function

I tried to use SUMIFS, but it failed since the formula doesn't allow me to use two different criterias from the same criteria range (which makes sense of course), so I looked around the Internet and found '=SUMPRODUCT' instead I used it but it doesn't return any value. Here my formula
=SUMPRODUCT((('BB_Juni 2016_Crew'!E:E="DB")+('BB_Juni 2016_Crew'!E:E="DZ"))*('BB_Juni 2016_Crew'!G:G))
Maybe Looping through the range with an if clause and using the sum function after "then"?
In row number 26 & 27 are two different string values ("DB,DZ") and in the same row is a value in the column (Betrag) which means amount and I need a formula to sum all values that are in the same rows as "DB" and "DZ"
I agree with Jeeped that you should "Cut your full column references down to the actual extents of your data"
There is a slight typo in your formula. Replace the * with a , and it will work just fine :)
Your original formula should be
=SUMPRODUCT((('BB_Juni 2016_Crew'!E1:E6="DB")+('BB_Juni 2016_Crew'!E1:E6="DZ")), 'BB_Juni 2016_Crew'!G1:G6)
Replace 6 with the relevant row.
This is the best I can improve your existing formula without more information.
=SUMPRODUCT(('BB_Juni 2016_Crew'!E1:INDEX('BB_Juni 2016_Crew'!E:E, MATCH("zzz", 'BB_Juni 2016_Crew'!E:E))={"DB","DZ"})*('BB_Juni 2016_Crew'!G1:INDEX('BB_Juni 2016_Crew'!G:G, MATCH("zzz", 'BB_Juni 2016_Crew'!E:E))))
It may look more complicated but it actually performs much less work.
Actually, this may be even better.
=SUM(SUMIFS('BB_Juni 2016_Crew'!G:G, 'BB_Juni 2016_Crew'!E:E, {"DB","DZ"}))
Both are standard formulas (no need for CSE).
There is a spreadsheet function AND that accepts several conditions and returns TRUE of all conditions are TRUE, FALSE otherwise.
You may try re-phrasing your formula or make your question clearer so it may be possible to give you an actual working formula.

Incremente row (VBA) and then Using SommeProduct (probleme with Sommeproduct Excel)

Thanks to help me)))
At first I incremente the row + 1 with the value that I have insert with VBA. That's working...
ThisWorkbook.Worksheets("Données Enregistrées").Range("A10:AL10").Copy _
Destination:=ThisWorkbook.Worksheets("Données Enregistrées").Cells(Rows.Count, 1).End(xlUp).Offset(1)
And then I want to use the value that I have insert to modify them..I use excel for that.. and I got 0...But If I insert value by hand that's working...
=SOMMEPROD((A16:A22=A2)*(B16:B22))
Any Solution??
Hope that you have understood, thanks)))
You can use Sommeprod (sumproduct for english) on entire columns like this :
=SOMMEPROD((A:A=D2)*(B:B)*1)
But if you test a value that is in the same column it can be a problem I think, so show us a bit more so we can answer more accurately!
And yes, SommeProd is an array formula so you have to do Ctrl+Shift+Enter when you are done typing it!
A bientôt

#Value! error with =(A1+A2)

I'm trying to add multiple cells with the formula =(A1+A2+A3...etc)
Which works, but if all the cells are empty then I get a #Value!
PLEASE NOTE:
Yes I am aware the proper way to add cell values is with =SUM(A1:A3)
However the cells I'm adding together each have their own functions to get their numbers, and the =SUM function won't add them together.
So! Is there a way I can make =(A1+A2+A3...etc) not give me a #Value! error in the cell that's supposed to total them if ALL the cells (A1,A2,etc) are empty? (as in, the cell with the total will just be blank)
Yes I know this is overly complicated. I'm working with that I've got.
EDIT
I might have figured out my problem. My 'false' statement in the function of the cells that were being added is "" in order to make the cell not have a 0 in it when empty. When it tries to add those cells together, if they all read "" and none are a number that's when I get the #Value! error. Not sure yet what I'm going to do about that...
EDIT 2
Yup. Problem was caused by having a non-numerical value as my false statement. Didn't want a bunch of zeros everywhere, but oh well I guess.
I tried both Excel 2007 and Calc 3.4.1, and neither one of these generated the #Value! that you mention. I am thinking that perhaps your source cells' equations are producing a value that is causing this to error out.
For example, if one of the cells has a String value, then this will be the result. This can be detected with the TYPE() function. for example:
=( IF(TYPE(A1)=1;A1;0) + IF(TYPE(A1)=1;B1;0) + ...)
this will make sure that you are actually adding numbers before the addition takes place.
edit
See: http://www.techonthenet.com/excel/formulas/type.php
for details on TYPE()