I cannot figure out why this formula isn't working:
=IF(A2="160850",TP,IF(A2="202006",BL,IF(A2="203646",MM,IF(A2="203917",KT,IF(A2="200265",MP,IF(A2="201447",JB,IF(A2="170566",VB"")))))))
Cell A2, A3, and so on, represent commossion codes that are specific to a sales rep.
So, if Cell A2 equals 160850, then I need the cell I place this formula in (C2) to display TP, and so on, based on the formula above.
I have checked and this looks okay to me. However, when I enter this formula in, I get a message that states The formula you entered contains an error.
Can anyone assist?
Thanks so much in advance
You need to put your return values inside quotes, otherwise Excel assumes that TP is a valid name in the workbook (i.e., an address, named range, or variable).
=IF(A2="160850","TP",IF(A2="202006","BL",IF(A2="203646","MM",IF(A2="203917","KT",IF(A2="200265","MP",IF(A2="201447","JB",IF(A2="170566","VB")))))))
There may be additional errors, but this one is apparent.
Wouldn't it be simpler to use a lookup table? List all your commission codes in one column, e.g. Y2:Y10 then list the linked sales rep (initials) in the next column (Z2:Z10) and you can then use this formula copied down the column
=VLOOKUP(A2,Y$2:Z$10,2,0)
The last set of double quotes should be parentheses:
=IF(A2="160850",TP,IF(A2="202006",BL,IF(A2="203646",MM,IF(A2="203917",KT,IF(A2="200265",MP,IF(A2="201447",JB,IF(A2="170566",VB)))))))
You also probably want to take the agent numbers out of quotes or it'll return false because the number entered is numeric and you're looking for a string. The Codes should be in quotes, though e.g. IF(A2=160850,"TP",....
Related
In order to do some calculations on averages and differences of values in columns, I've defined a name, based on a range, but it seems to be completely going berserk:
I have a cell (D13), defined as Header_First _Answer, which contains the title of the column, and I have a value (currently being 69), which contains the number of entries, called Total_Count.
I've defined the entries of that column as another name: "All_First_Answered_Dates", defined as =OFFSET(Header_First_Answer;1;0):OFFSET(Header_First_Answer;Total_Count;0) (start by the first entry under Header_First_Answer, take up to 69 entries, and define a range out of this).
In cell G5, I'm using that name in order to do some calculations (calculating averages), but this seems not to work (there is a #Value error).
After second comment from Rory: G5 formula and first formula evaluation result:
Formula:
=AVERAGE(IF(ISBLANK(All_First_Answered_Dates);TODAY();All_First_Answered_Dates) - All_Start_Dates)
First evaluation result:
=AVERAGE(IF(ISBLANK(#Value!);TODAY();All_First_Answered_Dates) - All_Start_Dates)
Hence, my conclusion:
After some checking I've found out that this is due to the name "All_First_Answered_Dates", which seems to be interpreted one time too many (or how do I explain this):
In different cells, I've entered the formula =OFFSET(Header_First_Answer;1;0):OFFSET(Header_First_Answer;Total_Count;0) (which is exactly the meaning of "All_First_Answered_Dates"), and every time, using the Evaluate Formula feature, I see that the last but one result is correct: $D$14:$D$82. However, after that, another evaluation is done, turning this value into 43283 (in case the formula is entered in "J14"), 43300 (in case the formula is entered in "J15"), ..., and in case I enter this formula in a cell with row number lower than 14, I have the error value #Value (which explains the wrong result in cell G5).
If I simply put the formula =$D$14:$D$82 in any of the mentioned cells, then the content of some cells in column D are shown (which are dates, not values like 43283 or 43300).
It appears that declaring a range as =x:y, where x and y are formula results, is not working.
Does anybody know how I can define a range as a formula, which I can then use in order to define in a name?
I can imagine my explanation being quite complicated without an image, hence the attached screenshot. In there:
In cell J13, there is the formula =OFFSET(Header_First_Answer;1;0):OFFSET(Header_First_Answer;Total_Count;0).
In cell J14, there is the same formula.
In cell K14, there is the formula =$D$14:$D$82.
For completion purposes, hereby a screenshot of the name manager, containing both mentioned names (the ones, selected in the name manager):
Edit after first comment:
The idea behind the range is the following:
1. Take the first row under Header_First_Answer, do not take any other column : OFFSET(Header_First_Answer;1;0)
2. Take the Total_Count's row under Header_First_Answer, do not take any other column : OFFSET(Header_First_Answer;Total_Count;0)
3. Define a range, based on those two cells, by putting a semicolon between them.
I was not aware of the height and width features of the Offset() worksheet function. I've implemented them, which makes the formulas much easier.
Unfortunately the problem still persists.
Thanks in advance
Dominique
I've just found the answer of what was going wrong:
The formula was meant to be an array formula. Something went wrong and while trying to debug, I accidently re-formatted the formula into a normal formula (I must have pressed "ENTER" instead of "Ctrl" + "Shift" + "ENTER") at some point.
I have re-applied array formula (using "Ctrl" + "Shift" + "ENTER"), getting a formula like:
{=AVERAGE(IF(ISBLANK(All_First_Answered_Dates);TODAY();All_First_Answered_Dates) - All_Start_Dates)}
(mind the braces {, })
Now everything is working fine.
As in title, I'm trying to compare two lists and when a formula hits the match I want it to type the text, but from the cell right next to the found matching cell.
For example: A list of 5343 positions B1:B5343 has corresponding reference numbers in A column (A1:A5343). F1 has a certain number. G1 ought to show the reference number, not the match itself.
I've tried to work with this formula:
=IF(ISERROR(MATCH(F1;$B$1:$B$5343;0));"";A1)
Where A1 should be the reference cell. Not fluent in Excel enough to know
is there a way to refer to a formula result?
is it possible to refer to a cell next to the cell of interest (or few away)? ex.(B-1)54=A54
Not sure how can I clarify the problem more than that :) Help me out please!
Eager to read Your answers! Cheers!
This is a typical case for Vlookup
i would probably go for a index match on this, so INDEX(C:C,MATCH(F1,B:B,0),1)
the index part will go get the cell next to it you want, just replace C:C with the column its in
If its not a match use iferror, rather than iserror as well, Its better practice.
SO : IFERROR( INDEX(C:C,MATCH(F1,B:B,0),1) ,"NO MATCH)
Heres a tutorial
I have need to enter a value that can vary. It is the last row in a column. I add this variable cell to A1. The value is $L$9001
I have the following formula: =VLOOKUP($H4,'week ending 04JUL'!$A$1:$L$9001,3,FALSE)
In A1 I have the value $L$9001. This figure may change hence why I need to add it in and can't use a hardcoded value.
In B1 to test I get the correct output I have: =INDIRECT("A1")
This returns $L$9001 as expected
When I try: =VLOOKUP($H4,'week ending 04JUL'!$A$1:INDIRECT("A1"),3,FALSE)
This returns a #VALUE error.
So I need the value in A1 to replace $L$9001 portion of the formula. Any help is greatly appreciated.
You're almost there, Indirect works slightly different. Try this:
=VLOOKUP($H4,Indirect("'week ending 04JUL'!$A$1:"&A1),3,FALSE)
You put the whole range in the Indirect() field, not just the part you're referring to. Also, note the use of quotes (") starting the Range, wrapping your reference into basically a string that Excel uses.
I am using this formula to search a range of cells for the letters "cc".
=COUNTIF(G4:G28,"cc")*G3
This lets us know who paid with a credit card. I was told that we also need to know the date. So now I am adding the date to the cell using this format "cc (10/03)" Of course now the formula does not count this cell because the formula is looking for "cc" only. So now I need to replace the "cc" part of the formula with something that looks in the cell for "cc". I think I can use ISNUMBER but that requires that I enter a specific cell in the formula. Since this formula is being used as part of a formula that contains a range, how would I do this?
Hope this makes sense.
Many thanks,
Houston
If you need to have the date in the same cell then you can use a "wildcard" * in COUNTIF like this
=COUNTIF(G4:G28,"cc*")*G3
then that will count all cells that start with "cc"....or a wildcard either side if you need, i.e.
=COUNTIF(G4:G28,"*cc*")*G3
which would count cells that contain "cc" anywhere.
Ideally you would put the date in a separate cell in the same row so that your original formula would still function OK
I've been working on VBA for so long I forgot how to do this...using formulas.
I have a cell that has a descriptor in it, in this case K1122121. The cell next to it, will be the description. On another sheet I have a list of parts, I need to look up said part number on sheet 2, and place the description next to the part it's looking up.
I know it's possible, I just forget how.
So to recap.
Sheet one has two cells, the first is a part number, the 2nd next to it, is where the formula is going, in this cell will produce the description to said part number.
Sheet two has part and description side by side. I need to reference the part number and find the description.
Once the description is found, place said description in the description field in sheet one.
Thanks for the help.
Here is a link of what I am working on. https://dl.dropbox.com/u/3327208/Excel/PAERTO.xlsm
It's called VLOOKUP and you call it like this:
=VLOOKUP(A1,Sheet2!A:B,2,FALSE)
Where:
A1 is the cell with the part number in sheet1
Sheet2 the sheet where the data is located (descriptor / description)
A:B is the range in sheet2 where the data is located
2 because what you are looking for is in the second column
FALSE to only get a value for exact matches - if no exact match is found, it will show an error
EDIT
Looking at your workbook, I would personally insert a new column in the jobs list (say between D and E) with a formula that only keeps the first word only - formula in E3:
=IF(ISERROR(FIND(" ",D3)),D3,LEFT(D3,FIND(" ",D3)-1))
Then the formula in the PAERTO sheet then becomes - formula in D20:
=VLOOKUP($E20,'Jobs List'!$E:$F,2,FALSE)
in the example you provided, I get a result for lines 20, 22 and 24, and an error on the other lines.
I can get a result if I use this formula:
=VLOOKUP(E20&" Rev"&F20,'Jobs List'!D:E,2,0)
However you need to change cell F20 to 4.
As long as part number and "Rev" are consistent between sheets, this formula should work.
Note that only cells D20 and D24 return values. The other part numbers don't exist on the other sheet, so regardless of what formula is used you will not see a return value.
With your part number in A1, in B1 the formula =VLOOKUP(A1,Sheet2!A:B,2,FALSE) will find the description
If you are on Excel 2003 or earlier, you will have to change Sheet2!A:B to be a full reference like Sheet2!A2:B2000
The answer was a little more complex than I was hoping, but I ended up using this as an answer. It may not be the most simplistic, or elegant, but it works.
=IF(E20=0,VLOOKUP("*"&E20&"*",'Jobs List'!D:E,2,FALSE),VLOOKUP("*"&E20&"*",'JL Archive'!D:E,2,FALSE))
I used the "*" to make it so that it utilized wild cards, something I never thought of using... but it works. I put the wildcard usage in front and behind so just in case any cells may have something more than the required text in the front of the part or behind it.
I hope this helps people. The original use for this was so I can use the formula can be used from another workbook, but as we all know this can be used anywhere. Enjoy :)