I hope to explain what I need in the right way.
I have to work with a huge number of data.
Those dataset are ordered in the same way and I need to take the same info from all.
The problem is that I am not able to set the cell in the formulas without editing all the formulas.
In the picture you can see that the dataset start at the line 74 and it involved 7 lines total
the formula is easy: =max(79:85) but I am not able to find an automatic way to set the interval.
The first item is the line "(start_dataset_line+5)" and the last one is "(first_item_line+total_numer_line)"
The formula shoud be =max(C$"valueinthecellB74+5":C$"valueinthecellB74+5+valueinthecellC74")
but I do not know how to write the non fixed bold expression
Is it possible to set in automatically even with a macro?
Thanks
you should use the INDIRECT function to calculate the range.
In your case
=MAX(INDIRECT("C"&B74+5&":C"&B74+4+C74))
Buona fortuna con Excel :)
This would do:
=MAX(OFFSET(C5;B74;0;C74;1))
Related
I've found similar examples through searching but I can't find anything that matches the issue that I have...
I have a table which shows parts received/rejected, I wish to see the maximum days early/late (I'll only need help with one as the other I can then do!)
- but there are dummy orders which I wish to ignore (they show a received/reject of 0).
Here is example data from the 'AnnualDump' sheet:
My current calculation is
=IF(ISBLANK(AnnualDump!$H$2),"BLANK",0-MIN(AnnualDump!$G:$G))
[Column H is Received/Rejected and G is VarianceDays]
This simply looks at if there is any data on the sheet before running the calculation, which is fantastic for 95% of the time... but I want to ignore any values that have a received/rejected of 0...
I want it to show 29, but it's showing 30 in this instance as it's not ignoring 0qty lines.
I've tried adding another IF statement but it didn't work :/
Completely stuck now and not sure what the next step to try is...
I can do it if I cheat (call both columns to another sheet, turn text white, use an 'IF cell greater than x, then value' to compare the whole lot and then min/max that third column) but I'm trying to avoid that!
Any pointers or help will be greatly appreciated (complete VBA noob in excel so I'd like to avoid that if possible).
Thanks
Try this array formula. Confirm with Ctrl, Shift and Enter and curly brackets will appear round the formula.
I would strongly suggest you don't use full column references though as these formulae are rather resource-intensive.
=IF(ISBLANK(AnnualDump!$H$2),"BLANK",0-MIN(IF(AnnualDump!$H:$H>0,AnnualDump!$G:$G)))
I'm using counting invoice numbers (text) in a table's column, but the Excel formula seems to be confusing some values.
I copied small sample of these - please refer to below:
The formulas are as follow:
=COUNTIFS(A1:A19,A1)
=COUNTIF(A1:A19,A1)
As you can see these invoice numbers differ and the results of these functions suggest as if all were the same.
I googled it for 1 hour but I didn't find such as issue as mine.
If anybody had any clue why could this behave in such way I'll be super grateful!
Rob
Each time you copy down this formula it will add 1 row to each. For example the second row of datas formula will be =COUNTIFS(A2:A20,A2). To lock these cells in the formula use $
Your formula should be =COUNTIFS(A$1:A$19,A1)
I've solved this myself:
ROOTCAUSE
Excel tried to be helpful and read these invoice numbers as actual numbers (despite these being defined already in Power Query as text)
Then, Excel fooled me and despite showing that it works on it as a string (I was evaluating the formula) it worked on it as number
Above means that it transformed exemplary "00100001010000018525" to 1.00001E+17, which cut down this to "100001010000018000" - that's the moment Excel stopped fooling around and showed that value in the formula bar.
I think I don't need to tell why countif perceived all these values as equal.
SOLUTION
I simply appended one letter after each invoice number to get e.g. "00100001010000018525a" what forces Excel to quit its gimmicks and games.
Case closed.
I suspect this is a bug in COUNTIF, or maybe by design.
However, to workaround this in the formula, without having to change your data, try adding a wild-card character:
=COUNTIF(A1:A19,"*"&A1)
I have the following formula in an excel sheet that generally works perfectly:
=IF(F5>=30.01,(39+(C5*0.08)),IF(AND(F5>=20.01,F5<=30),(39+(C5*0.07)),IF(AND(F5>=10.01,F5<=20),(39+(C5*0.06)),IF(AND(F5>=5.01,F5<=10),(39+(C5*0.05)),IF(AND(F5>=2.01,F5<=5),(39+(C5*0.04)),IF(AND(F5>=1.01,F5<=2),(39+(C5*0.03)),IF(AND(F5>=0.25,F5<=1),(39+(C5*0.02)),IF(AND(F5>=0,F5<=0.245),(0.03*C5*F5)))))))))
I was just wondering if anyone could tell me how to edit this so that if the result of the formula is less than '43', that the number inputted into the cell should be 43?
I have been trying to edit this accordingly for a while and I'm not sure what I need to do to make that happen.
The rest of the formula works exactly as I need it to, I just need the sheet not to produce a result that is less than 43.
Thank you so much for all your assistance!
You don't need the AND statements as the very nature of the nested ifs picks them off scaling down, Here is your current formula amended:
=IF(F5>=30.01,(39+(C5*0.08)),IF(F5>=20.01,(39+(C5*0.07)),IF(F5>=10.01,(39+(C5*0.06)),IF(F5>=5.01,(39+(C5*0.05)),IF(F5>=2.01,(39+(C5*0.04)),IF(F5>=1.01,(39+(C5*0.03)),IF(F5>=0.25,(39+(C5*0.02)),IF(F5>=0,(0.03*C5*F5)))))))))
You could then wrap it in a MAX formula to get either the result or 43, whichever is larger like so:
=MAX(IF(F5>=30.01,(39+(C5*0.08)),IF(F5>=20.01,(39+(C5*0.07)),IF(F5>=10.01,(39+(C5*0.06)),IF(F5>=5.01,(39+(C5*0.05)),IF(F5>=2.01,(39+(C5*0.04)),IF(F5>=1.01,(39+(C5*0.03)),IF(F5>=0.25,(39+(C5*0.02)),IF(F5>=0,(0.03*C5*F5))))))))),43)
the formula can also be adjusted further in order to group common factors as follows:
=MAX(SUM(IF(F5<=0,0,39),
IF(F5>30,(C5*0.08),
IF(F5>20,(C5*0.07),
IF(F5>10,(C5*0.06),
IF(F5>5,(C5*0.05),
IF(F5>2,(C5*0.04),
IF(F5>1,(C5*0.03),
IF(F5>=0.25,(C5*0.02),
IF(F5>=0,(0.03*C5*F5),0))))))))),43)
Long formulas are always difficult to read, may I suggest to use the Alt+Enter keys combined to start a new line in the same cell thus breaking your formula in several lines within the same cell.
Certainly, The revised formula should be like this:
=IF(F5=0,0,
MAX(SUM(IF(F5<=0,0,39),
IF(F5>30,(C5*0.08),
IF(F5>20,(C5*0.07),
IF(F5>10,(C5*0.06),
IF(F5>5,(C5*0.05),
IF(F5>2,(C5*0.04),
IF(F5>1,(C5*0.03),
IF(F5>=0.25,(C5*0.02),
IF(F5>=0,(0.03*C5*F5),0))))))))),43))
First time question and I hope it's easier than I'm making this.
Can I use a variable inside a COUNTIF formula?
Currently my formula is:
=COUNTIF($C$2:$C$415,R6)
I would like to have $415 as my variable. I have tried something along the lines of:
D1=415=COUNTIF($C$2:$C$(D1),R6) ..
but obviously get a error.
The reason I need this is column C will constantly be incrementing as I add more rows.
Instead of going into each of my formulas and updated 415 to 416, 417 etc, I would like to just define a Cell that can be my variable, or total rows.
Currently Column C can have blank cells, so I can't have a macro that finds the next empty cell.. but I do however have Column A with a constant populated cell and stops at the last ticket. However Column A is unrelated to the COUNTIF.
UPDATE 1
I'd also like to mention that I'd be using this variable in many formulas in the spreadsheet. Not only COUNTIF's. Also, the COUNTIF contains text.
UPDATE 2
Actually, I figured it out! I am using this formula instead:
=COUNTIF(INDIRECT("C"&D1&":A"&D2),R6)
I'm putting D1=2 and D2=415 and will just update cell D2 with how many rows I have.
I guess I just needed to ask the question thoroughly to fully understand what I wanted!
Thank you in advance for all help, tips and suggestions.
Would "=COUNTIF($C:$C,R6)" do the trick? This will apply COUNTIF to the whole of column C. It's an easy solution, but probably not the most efficient.
I prefer tables for storing data; as new data is added, the table automatically expands and the columns are already labeled (much like Named Ranges). Then you can have =COUNTIF(Table1[Column1],"Criteria"), which will encompass any new rows added to the table automatically. Especially helpful if you have multiple tables in the same column.
I have a SUM array formula that has multiple nested IF statements, making it very inefficient. My formula spans over 500 rows, but here is a simple version of it:
{=SUM(IF(IF(A1:A5>A7:A11,A1:A5,A7:A11)-A13:A17>0,
IF(A1:A5>A7:A11,A1:A5,A7:A11)-A13:A17,0))}
As you can see, the first half of the formula checks where the array is greater than zero, and if they are, it sums those in the second part of the formula.
You will notice that the same IF statement is repeated in there twice, which to me is inefficient, but is the only way I could get the correct answer.
The example data I have is as follows:
Sample Data in spreadsheet http://clients.estatemaster.net/SecureClientSite/Download/TempFiles/example.jpg
The answer should be 350 in this instance using the formula I mentioned above.
If I tried to put in a MAX statement within the array, therefore removing the test to find where it was greater than zero, so it was like this:
{=SUM(MAX(IF(B2:B6>B8:B12,B2:B6,B8:B12)-B14:B18,0))}
However, it seems like it only calculates the first row of data in each range, and it gave me the wrong answer of 70.
Does anyone know a away that I can reduce the size of the formula or make it more efficient by not needing to repeat an IF statement in there?
UPDATE
Jimmy
The MAX formula you suggested didnt actually work for all scenarios.
If i changed my sample data in rows 1 to 5 as below (showing that some of the numbers are greater than their respective cells in rows 7 to 11, while some of the numbers are lower)
Sample Data in spreadsheet http://clients.estatemaster.net/SecureClientSite/Download/TempFiles/example2.jpg
The correct answer im trying to achive is 310, however you suggested MAX formula gives an incorrect answer of 275.
Im guessing the formula needs to be an array function to give the correct answer.
Any other suggestions?
=MAX( MAX( sum(A1:A5), sum(A7:A11) ) - sum(A13:A17), 0)
A more calculation-efficient (and especially re-calculation efficient) way is to use helper columns instead of array formulae:
C1: =MAX(A1,A7)-A13
D1: =IF(C1>0,C1,0)
copy both these down 5 rows
E1: =SUM(D1:D5)
Excel will then only recalculate the formulae dependent on any changed value, rather than having to calculate all the virtual columns implied by the array formula every time any single number changes. And its doing less calculations even if you change all the numbers.
You may want to look into the VB Macro editor. In the Tools Menu, go to Macros and select Visual basic Editor. This gives a whole programming environment where you can write your own function.
VB is a simple programming language and google has all the guidebooks you need.
There, you can write a function like MySum() and have it do whatever math you really need it to, in a clear way written by yourself.
I pulled this off google, and it looks like a good guide to setting this all up.
http://office.microsoft.com/en-us/excel/HA011117011033.aspx
This seems to work:
{=SUM(IF(A1:A5>A7:A11,A1:A5-A13:A17,A7:A11-A13:A17))}
EDIT
- doesn't handle cases where subtraction ends up negative
This works - but is it more efficient???
{=SUM(IF(IF(A1:A5>A7:A11,A1:A5,A7:A11)>A13:A17,IF(A1:A5>A7:A11,A1:A5,A7:A11)-A13:A17,0))}
What about this?
=MAX(SUM(IF(A1:A5>A7:A11, A1:A5, A7:A11))-SUM(A13:A17), 0)
Edit:
Woops - Missed the throwing out negatives part. What about this? Not sure it it's faster...
=SUM((IF(A1:A5>A7:A11,IF(A1:A5>A13:A17,A1:A5,A13:A17),IF(A7:A11>A13:A17,A7:A11,A13:A17))-A13:A17))
Edit 2:
How does this perform for you?
=SUM((((A1:A5>A13:A17)+(A7:A11>A13:A17))>0)*(IF(A1:A5>A7:A11,A1:A5,A7:A11)-A13:A17))