Using pre-specified formulas elsewhere in Excel - excel

I am trying to use pre-specified formulas in excel that can simply be referenced and used anywhere in the workbook, without using VBA. The following example illustrates how I wish this to work.
In the following example, the Forumla Specs section lists various functions we would like to use elsewhere in the workbook
The Formula Use section shows how we would like to use them. How would I call the function in the specs area to calculate the calc1 column (and calc2, calc3, etc.) across the variables d1-d4 using the formula specified in Formula Specs for calc1? I would like to use a generic formula that we can use universally to only depend on the column heading (i.e calc1, calc2, etc)?
We have tried using range names, index function, vlookups and various combinations of these to try and achieve this fete, but with no success.
Example
Formula Specs
Calculation Function
calc1 sum(d1,d2,d3,d4)
calc2 sum(d2,d3)
calc3 100*(d4/d3)
Formula Use
obs d1 d2 d3 d4 calc1 calc2 calc3
obs1 24 45 14 41 124 59 292.8571429
obs2 19 28 47 34 128
obs3 29 32 20 24 105
obs4 40 43 28 12 123
obs5 39 16 11 40 106
obs6 17 14 38 14 83
obs7 47 38 26 24 135
obs8 31 25 46 15 117
obs9 25 15 48 11 99
obs10 30 35 32 30 127
obs11 41 43 18 15 117
obs12 10 34 30 47 121
obs13 44 23 10 22 99
Please help!

This is a duplicate of Getting formula of another cell in target cell
Short answer is that you can't without VBA. Also, I don't know why you are so adament about not using UDFs as they are not very complicated to learn about if you are not familiar with VBA.

You could use Named Ranges to achieve this:
Select the first cell you want calc1 to be used in
Create a new named range called calc1
Set its Refers To value to =sum(d1,d2,d3,d4)
Put the formula =calc1 into the cell
Now, when you enter the formula =calc1 into another cell, it will sum cells relative to the new cell.
If you don't want it to be relative, use absolute references in the named range, eg =Sum($D1,$D2)
Tried and tested on Excel 2010

Related

Look up Cell data based on Month header in table with two cells as reference

Some days ago i got help from Scott Craner with an formula for a 3D index match which works great.
I have tried expanding on it without any results, hopefully you can point out what i'm doing wrong.
Output list
Group Division Input Verification Differance
G1 1 120 123 =Sum([#[Input]]-[#[Verification])
G2 2 76 110 =Sum([#[Input]]-[#[Verification])
G3 3 110 90 =Sum([#[Input]]-[#[Verification])
G4 4 34 53 =Sum([#[Input]]-[#[Verification])
Data list
Group Division Year Jan Feb Mar Apr
G1 1 2017 123 95 80
G2 2 2017 110 85 75
G3 3 2017 90 80 70
G4 4 2017 53 53 46
Following code is the one im trying to use, using only Group as a lookup i get a value
=INDEX(DataList,MATCH([#Group]:[#Division],DataList[Group]:DataList[Division],0),MATCH(TEXT($A$1,"mmm"),DataList[#Headers],0))
I have tried different variations,
Binding the results together with an &,
Tried binding just one result with & and the other one with a simple :
nothing has produced a good result in some cases i get a result, in others i do not get anything.
If i only use Group as a lookup term it's not an issue, it returns the correct value, but I'm trying to Index match two cells with two other cells.
I have evaluated the code and it does not return a value and I do not know what i'm doing incorrectly

Look up Cell data based on Month header in table

i'm trying to create a small spreadsheet for data verification.
Below i have created two tables Table 1 and Table 2.
What i am trying to find is a simple =Index Match or similar to check for Current month then copy that value to respective Group row under verification.
Problem is that the months are a header row and i have no idea how to check a header row for correct month then output the values in the cells below it to each corresponding group in the output list.
So to put it in programming terms this is what im looking for
If A2=Table2[Header] then c8=C4 else table[header] + step right
A2 contains todays Date (=today()) and Header has the shorten Month names as Jan Feb Mar and so on.
Something similar as above, i don't know if i'm making it harder for me then it really should be. I'm working with Excel 2013.
Output list
Group Input Verification Differance
G1 120 123 =Sum([#[Input]]-[#[Verification])
G2 76 110 =Sum([#[Input]]-[#[Verification])
G3 110 90 =Sum([#[Input]]-[#[Verification])
G4 34 53 =Sum([#[Input]]-[#[Verification])
Data list
Group Year Jan Feb Mar Apr
G1 2017 123 95 80
G2 2017 110 85 75
G3 2017 90 80 70
G4 2017 53 53 46
Regards
Johan
You would use a second match to find the correct column:
=INDEX(DataList,MATCH([#Group],DataList[Group],0),MATCH(TEXT($A$1,"mmm"),DataList[#Headers],0))

Return max index value in vlookup

I'm trying to pair a vlookup with a max function. For some reason it only returns #ref every time I try to use it though.
My sheet looks like this:
A - B - C - D - E - F - G
1...
5 - Prod5 id1 $100 $125 $155 $110 $150
6...
A:G is named buyAverages
C:G is named buyAveragesPrices
What I want to do is have a vlookup go and find a value in Col A and then return the highest value in that Col. So example:
A - B
1 - Prod5 *return highest price for Prod5
What I wrote in B1, which failed:
VLOOKUP(A1,buyAverages,MAX(buyAveragesPrices))
So how do I achieve this lookup? Everything I have found is how to use MAX for the lookup value, but nothing to use max on the returned index.
Try this
=MAX(IF(A:A="Prod1",C:G))
This is an Array Formula. i.e you have to press Ctrl+Shift+Enter
If there's only one instance of each Product then you can use INDEX/MATCH like this
=MAX(INDEX(C2:G100,MATCH("Prod 1",A2:A100,0),0))
Longer than Sid's suggestion but doesn't need CSE and might be more efficient if you only have a single match
If you have that formula in Z2, for example, you can use this version to get the location from row 1
=INDEX(C1:G1,MATCH(Z2,INDEX(C2:G100,MATCH("Prod 1",A2:A100,0),0),0))
You can have all in one cell using Vlookup and Max with a nested formula. For example at the top of the page:
A1 = Select the name of the product you want to find the max
A2= MAX(BUSCARV($A$1;$A$3:$F$11;3;FALSO);BUSCARV($A$1;$A$3:$F$11;4;FALSO)
;BUSCARV($A$1;$A$3:$F$11;5;FALSO);BUSCARV($A$1;$A$3:$F$11;6;FALSO))
It's long but you only have to type it once. With this formula we get all the different amounts in each column and then we ask for the maximum. It works if all the products are different. Change the name of the product and you'll find the MAX in the table.
Example Prod8
Prod8 41 ; If we change and you select in A1 Prod4 you'll
get 70 and so on..
Prod1 id1 100 125 155 110
Prod2 50 25 20 75
Prod3 60 65 15 90
Prod4 70 12 50 43
Prod5 100 200 80 25
Prod6 20 28 40 40
Prod7 14 43 60 80
Prod8 22 33 15 41
Prod9 65 48 50 70
Select your range accordingly.
You also could include in A1 a match code to select the name of your products..

How to consolidate rows in excel in this scenario

I have two Columns. Column A has Part Numbers, Column B has Makes. After cleaning up my table I end up with duplicates in Column A. What I want to do is be able to consolidate all the makes to one unique part number in Column A. I tried posting a pictures but I can't yet because this is my first question.
I hope this makes sense. I just want to be able to create a formula or something that consolidates the part number. This will allow me to do a vlookup and bring all the makes into one cell which is my goal. Thank you!
PART NUMBER MAKE PART NUMBER MAKE
23 HOVERTECHNICS 23 HOVERTECHNICS
25 CUSHMAN 25 CUSHMAN
26 ARGO 26 ARGO
45 ALLSTATE 45 ALLSTATE,CUSHMAN
45 CUSHMAN 46 CUSHMAN
46 CUSHMAN 63 ROKETA
63 ROKETA 64 CAN-AM,HUSQVARNA,KAWASAKI
64 CAN-AM 66 E-Z GO,KAWASAKI,SUZUKI,YAMAHA
64 HUSQVARNA 85 HARLEY-DAVIDSON
64 KAWASAKI 255 ARGO,CLINTON,FRONTIER-TML (Quadra), HEALD, HEALTH KIT
66 E-Z GO
66 KAWASAKI
66 SUZUKI
66 YAMAHA
85 HARLEY-DAVIDSON
255 ARGO
255 CLINTON
255 FRONTIER-TML (Quadra)
255 HEALD
255 HEATH KIT
The end result that I wish for looks like the example on the right.
I'm not sure if this is possible on a mac, if so I have windows as well Excel 2007.
Assuming your source is in ColumnsA & B, with a header row in Row1, then copy B2 into D2 and:
in C2: =IF(A2=A3,"",A2) copied down to suit,
in D3: =IF(A3=A2,D2&", "&B3,B3) copied down to suit.
Then copy ColumnsC&D and Paste Special Values into a new sheet. Filter there to select blanks in the PART NUMBER column and delete selected rows. Unfilter.

Excel nesting error

I'm using Excel 2013 and I have had to create a If statement which basically chooses a student's grade depending on a certain mark number (obviously, nesting is needed) Here is the If statement I created:
=IF(E2<=20,"N",
IF(OR(E2>=21,E2<=25),4,
IF(OR(E2>=26,E2<=32),"5C",
IF(OR(E2>=33,E2<=38),"5B",
IF(OR(E2>=39, E2<=44), "5A",
IF(OR(E2>=45, E2<=53), "6C",
IF(OR(E2>=54, E2<=61), "6B",
IF(OR(E2>=62, E2<=71), "6A",
IF(OR(E2>=72, E2<=87), "7C",
IF(OR(E2>=88, E2<=103), "7B",
IF(OR(E2>=104, E2<=120), "7A")))))))))))
The error I receive is:
the specified formula cannot be entered because it uses more levels of nesting than allowed in the current file format
My question is, how do I shorten this statement to allow Excel to use it?
Place the logic in the spreadsheet cells. One column for the minimum score, and one column for the grade-:
A B
1 0 N
2 21 4
3 26 5C
4 33 5B
5 39 5A
6 45 6C
7 54 6B
8 72 7C
9 88 7B
10 104 7A
Then do a vlookup to get the grade from the actual score. vlookup will find the highest value in the A column that is less that the lookup value of 38.
In the example vlookup below 38 is the score, A1:B10 is the lookup table 2 is the 2nd column (in this case the B column) that contains the result (the grade).
=VLOOKUP(38, A1:B3, 2, TRUE)
You can also use the following formula.
=LOOKUP(E2;{0;21;26;33;39;45;54;62;72;88;104;121};{"N";4;"5C";"5B";"5A";"6C";"6B";"6A";"7C";"7B";"7C";"No match"})
There are a few different solutions. AND agreements using OR instead of the first that comes to mind.
=IF(E2<=20,"N",
IF(AND(E2>=21,E2<=25),4,
IF(AND(E2>=26,E2<=32),"5C", ...
The best way, in my opinion, is to write a UDF. Then you can use VBA and a CASE statement.
Experiment with this code in VBA to create a UDF named GRADE() - just type it into a MODULE in the VBE:
Function Grade(Marks)
Dim Score As Integer
Score = Marks * 1
Select Case Score
Case 1 To 20
Grade = "N"
Case 21 To 50
Grade = "C"
Case 51 To 90
Grade = "B"
Case 91 To 120
Grade = "A"
End Select
End Function
Then use the Function GRADE() as you would any other function but type the address of the argument - like this GRADE(B7) to use it
=+IF(O3="Negative","Negative",IF(P3="Negative","Negative",IF(Q3="Negative","Negative",IF(R3="Negative","Negative",IF(O3="Refer","Refer",IF(P3="Refer","Refer",IF(Q3="Refer","Refer",IF(R3="Refer","Refer","Positive"))))))))
I find the final status in 4 cells have positive,negative,refer,pending or blank

Resources