+ Reply to Thread
Results 1 to 27 of 27

How can I replace a CELL with an IF statement containing that same cell?

  1. #1
    Registered User
    Join Date
    08-28-2014
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    18

    Smile How can I replace a CELL with an IF statement containing that same cell?

    IF my A column has the following cells:

    $B$2
    $D$3
    $F$9
    $B$4
    .
    .
    .
    (2000 such values)

    How can I get my B Column to be:


    =IF($B$2=0,"NA",IF($B$2=1,"excellent",IF($B$2=2,"Good",IF($B$2=3,"Fair",IF($B$2=4,"Poor",IF($B$2=5,"Very Poor"))))))
    =IF($D$3=0,"NA",IF($D$3=1,"excellent",IF($D$3=2,"Good",IF($D$3=3,"Fair",IF($D$3=4,"Poor",IF($D$3=5,"Very Poor"))))))
    =IF($F$9=0,"NA",IF($F$9=1,"excellent",IF($F$9=2,"Good",IF($F$9=3,"Fair",IF($F$9=4,"Poor",IF($F$9=5,"Very Poor"))))))
    =IF($B$4=0,"NA",IF($B$4=1,"excellent",IF($B$4=2,"Good",IF($B$4=3,"Fair",IF($B$4=4,"Poor",IF($B$4=5,"Very Poor"))))))
    .
    .
    .
    (2000 such values)



    How can I do this without manually going through each cell? Can I use replace?

    I tried replacing :

    " $*$* "

    with

    " =IF($*$*=0,"NA",IF($*$*=1,"excellent",IF($*$*=2,"Good",IF($*$*=3,"Fair",IF($*$*=4,"Poor",IF($*$*=5,"Very Poor")))))) "

    But it doesnt seem to know what I'm trying to do. It wont associate each pair of wildcard *'s .

    Any help on this would be greatly appreciated!

    Thanks!

    -Panos-

  2. #2
    Valued Forum Contributor
    Join Date
    07-07-2014
    Location
    Washington DC
    MS-Off Ver
    2007
    Posts
    1,047

    Re: How can I replace a CELL with an IF statement containing that same cell?

    Can you upload a sample file showing what you're trying to accomplish?

  3. #3
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: How can I replace a CELL with an IF statement containing that same cell?

    Try indirect, and a choose will make the formula shorter!

    =IFERROR(CHOOSE(INDIRECT(A1),"Excellent","Good","Fair","Poor","Very Poor"),"NA")
    You should hit F5, because chances are I've edited this post at least 5 times.
    Example of Array Formulas
    Quote Originally Posted by Jacc View Post
    Sorry, your description makes no sense. I just made some formula that looks interesting cause I had nothing else to do.
    Click the * below on any post that helped you.

  4. #4
    Registered User
    Join Date
    06-27-2013
    Location
    Boulder, CO
    MS-Off Ver
    Excel 2007
    Posts
    99

    Re: How can I replace a CELL with an IF statement containing that same cell?

    Can't you write your B column to say
    =IF(A1=0,"NA",IF($B$2=1,"excellent",IF($B$2=2,"Good",IF($B$2=3,"Fair",IF($B$2=4,"Poor",IF($B$2=5,"Very Poor"))))))
    and copy that down, seeing as the A column is already referencing the other cell?

    Hope that helps.

    -Z

  5. #5
    Registered User
    Join Date
    08-28-2014
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    18

    Re: How can I replace a CELL with an IF statement containing that same cell?

    My B column in my example shouldn't correlate to the $B$2 . Instead of $B$* lets say its $Q$*. I will be copying this all later into a separate excel file later to arrange data.

    In the proposed file (with A and B being arbitrary columns I chose) am trying to replace the cell values : $Q$2 and the other $(Letter)$* in column A with their associated IF statements I proposed in column B. Each $(Letter)$* will be therefore associated with an individual IF statement containing that $(Letter)$*.

    Example :

    A1 : $Q$2
    A2 : $D$3
    A4 : $F$9
    A5 : $Q$4

    What I want to automate

    B1 : =IF($Q$2=0,"NA",IF($Q$2=1,"excellent",IF($B$2=2,"Good",IF($Q$2=3,"Fair",IF($Q$2=4,"Poor",IF($Q$2=5,"Very Poor"))))))
    B2 : =IF($D$3=0,"NA",IF($Q$2=1,"excellent",IF($D$3=2,"Good",IF($D$3=3,"Fair",IF($D$3=4,"Poor",IF($D$3=5,"Very Poor"))))))
    B3 : etc
    B4 : etc
    B5 : etc

    When I copy this new column B into my data file it will be pasted in an arbitrary position on the sheet (where Q,D,F are) and sort the data accordingly.

  6. #6
    Registered User
    Join Date
    08-28-2014
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    18

    Re: How can I replace a CELL with an IF statement containing that same cell?

    Quote Originally Posted by Speshul View Post
    Try indirect, and a choose will make the formula shorter!

    =IFERROR(CHOOSE(INDIRECT(A1),"Excellent","Good","Fair","Poor","Very Poor"),"NA")
    Im not quite sure how to use this.. Can you make column B have the associated IF statements? How can I upload an excel file onto here?

  7. #7
    Registered User
    Join Date
    08-28-2014
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    18

    Re: How can I replace a CELL with an IF statement containing that same cell?

    All I need is column B. When I suggested replacing, i meant replacing column A with B. All I need is a list of the IF statements (column B) .

  8. #8
    Registered User
    Join Date
    08-28-2014
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    18

    Re: How can I replace a CELL with an IF statement containing that same cell?

    Can anyone help? This is still unsolved

  9. #9
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: How can I replace a CELL with an IF statement containing that same cell?

    You say Column A has a bunch of cell references, as in the cells contain the text $Q$2 correct?

    You want a formula to look at cell A1, which has $Q$2, and return the value (1,2,3,4,5) that is in Q2, then convert it into the grading excellent to poor?

    Put
    =IFERROR(CHOOSE(INDIRECT(A1),"Excellent","Good","Fair","Poor","Very Poor"),"NA")


    Into B1, and it will look at cell A1. If cell A1 has a "$Q$2" in it, the formula will look at the value in Q2's cell and return your ranking.

    You don't need IF statements, you can use a choose in this scenario (because your values are 1,2,3,4,5)

    To upload a file go to "go Advanced" on the bottom. There is a paperclip looking icon on there that lets you include files.
    Last edited by Speshul; 08-29-2014 at 02:28 PM.

  10. #10
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: How can I replace a CELL with an IF statement containing that same cell?

    If you really want to use IF statements instead, the formula would look like:

    =IF(INDIRECT(A1)=0,"NA",IF(INDIRECT(A1)=1,"excellent",IF(INDIRECT(A1)=2,"Good",IF(INDIRECT(A1)=3,"Fair",IF(INDIRECT(A1)=4,"Poor",IF(INDIRECT(A1)=5,"Very Poor"))))))


    Personally I think the choose is easier

  11. #11
    Registered User
    Join Date
    08-28-2014
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    18

    Re: How can I replace a CELL with an IF statement containing that same cell?

    test.xlsx

    Thanks for the reply! But I need column B's cells to assosiate with column A's cells. They arent in any specific order (column A is made up of random $(Letter)$* cells) , But can I autofill by dragging down? Try to make all of column B into what I askd, in my uploaded file! Thanks

  12. #12
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: How can I replace a CELL with an IF statement containing that same cell?

    Well, one important detail I didn't know about was the = before the text in column A. I was under the impression A1 contained the text "$D&2", which is completely different than "=$D$2".

    Looking at it now.
    Last edited by Speshul; 08-29-2014 at 04:20 PM.

  13. #13
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: How can I replace a CELL with an IF statement containing that same cell?

    EDIT:

    Ok. Insert a new Column after column A

    Highlight all of Column A

    Go to the Data Tab, select "Text to Columns" button (near the middle)

    Click the "Delimited" option

    In the Textbox that says Other, enter an equals sign.

    Hit Finish

    Now Delete Column A

    Your new column A now has only cell references. Use the formula
    =IFERROR(CHOOSE(INDIRECT(A1),"Excellent","Good","Fair","Poor","Very Poor"),"NA")
    starting in B1

    Ignore my attachment that was a previous answer which is inefficient.
    Attached Files Attached Files
    Last edited by Speshul; 08-29-2014 at 02:56 PM. Reason: Figured out an easier way.

  14. #14
    Registered User
    Join Date
    08-28-2014
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    18

    Re: How can I replace a CELL with an IF statement containing that same cell?

    What I need is a list like the following (the actual charaters in each line (3 in example), not just the values).


    Need the following text in full:

    =IF($D$13=0,"NA",IF($D$13=1,"excellent",IF($D$13=2,"Good",IF($D$13=3,"Fair",IF($D$13=4,"Poor",IF($D$13=5,"Very Poor"))))))
    =IF($D$18=0,"NA",IF($D$18=1,"excellent",IF($D$18=2,"Good",IF($D$18=3,"Fair",IF($D$18=4,"Poor",IF($D$18=5,"Very Poor"))))))
    =IF($D$21=0,"NA",IF($D$21=1,"excellent",IF($D$21=2,"Good",IF($D$21=3,"Fair",IF($D$21=4,"Poor",IF($D$21=5,"Very Poor"))))))
    .
    .
    .
    etc

    This new coloumn will then be copied over to my raw data file, and convert my numbers to words, regardless of where I paste it! My problem is I have many files of such data and dont want to have to do anything but paste once per file!

    Is there any way to actually obtain these?

  15. #15
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: How can I replace a CELL with an IF statement containing that same cell?

    Upload a file with the problem on one tab, and the solution you are expecting on another tab.

  16. #16
    Registered User
    Join Date
    08-28-2014
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    18

    Re: How can I replace a CELL with an IF statement containing that same cell?

    Actually I can work backwards with what you provided! It might just work! Can you modify the function to have ISBLANK? If it is blank I want it to not show any value (blank) not NA. (this is to distinguish between zero and blank).

  17. #17
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: How can I replace a CELL with an IF statement containing that same cell?

    =IF(ISBLANK(IFERROR(CHOOSE(INDIRECT(A1),"Excellent","Good","Fair","Poor","Very Poor"),"NA")),"",IFERROR(CHOOSE(INDIRECT(A1),"Excellent","Good","Fair","Poor","Very Poor"),""))

  18. #18
    Registered User
    Join Date
    08-28-2014
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    18

    Re: How can I replace a CELL with an IF statement containing that same cell?

    Actually hmm.... the positions change for B1-B* on the data files.. so your solution wont work as I will be also using other word to number conversions that I cant have mixed up. Ill upload what you asked! here
    Attached Files Attached Files
    Last edited by polyzp; 08-29-2014 at 05:06 PM.

  19. #19
    Registered User
    Join Date
    08-28-2014
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    18

    Re: How can I replace a CELL with an IF statement containing that same cell?

    Ignore that file ! Ill update it!

  20. #20
    Registered User
    Join Date
    08-28-2014
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    18

    Re: How can I replace a CELL with an IF statement containing that same cell?

    Heres the updated file you asked for!

    testhelp2.xlsx

    Thanks for your help!
    Attached Files Attached Files

  21. #21
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: How can I replace a CELL with an IF statement containing that same cell?

    "I NEED THE "$D$13" for example to be in the actual formula above!"

    Do me a favor

    1. Make a spreadsheet, in cell A1 type "B2"
    2. Put a number into B2. Lets make it 4
    3. In cell A5 type =INDIRECT(A1)
    4. In cell A6 type "=B2"




    Notice how both become a 4

    INDIRECT does exactly what you are asking for a formula to do. CHOOSE can be used instead of IF, because CHOOSE:

    =CHOOSE(IndexNumber,1,2,3,4,5,6,7)
    so
    =CHOOSE(4,"a","b","c","d","e") will select D, because it is the 4th item.


    If it's not the RESULT of the formula you need, but rather the TEXT of the written out formula, you will need to write a macro to do that. TEXT values can't be automatically changed within a formula.

  22. #22
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: How can I replace a CELL with an IF statement containing that same cell?

    Ah, the plot thickens.

    Your updated file, in A1:
    =$D$15
    In B1:
    =IF($D$13=0,"NA",IF($D$13=1,"excellent",IF($D$13=2,"Good",IF($D$13=3,"Fair",IF($D$13=4,"Poor",IF($D$13=5,"Very Poor"))))))

    A2:
    =$D$17
    B2:
    =IF($D$18=0,"NA",IF($D$18=1,"excellent",IF($D$18=2,"Good",IF($D$18=3,"Fair",IF($D$18=4,"Poor",IF($D$18=5,"Very Poor"))))))

    Please kindly refer to my signature.

  23. #23
    Registered User
    Join Date
    08-28-2014
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    18

    Re: How can I replace a CELL with an IF statement containing that same cell?

    I get #REF in cell A5 when I did what you asked. problem.xlsx


    How could I write a macro to do such a thing? It is the text im after! This is only because im going to later use this with other excel files where B1-B* for example arent alligned with the proper 1-5 : "word" designation.

  24. #24
    Registered User
    Join Date
    08-28-2014
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    18

    Re: How can I replace a CELL with an IF statement containing that same cell?

    A1 and B1 in testhelp2.xml are not the A and B I was talking about earlier.

    B1 and B1 from both sheets in testhelp2.xml are A and B from my original post. Im simply trying to replace the "$D$13" text in the cell to a function with the text "$D$13" in it.

    Im trying to get B column from sheet 1 from B column from sheet 2.
    Last edited by polyzp; 08-29-2014 at 05:20 PM.

  25. #25
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: How can I replace a CELL with an IF statement containing that same cell?

    Quote Originally Posted by polyzp View Post
    I get #REF in cell A5 when I did what you asked. Attachment 342246


    How could I write a macro to do such a thing? It is the text im after! This is only because im going to later use this with other excel files where B1-B* for example arent alligned with the proper 1-5 : "word" designation.
    I said put "B2" in cell A1 (without quotes!). I never said anything about an equals sign.
    Last edited by Speshul; 08-29-2014 at 05:26 PM.

  26. #26
    Registered User
    Join Date
    08-28-2014
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    18

    Re: How can I replace a CELL with an IF statement containing that same cell?

    Oh I see! I just dont know how this helps my problem because im still going to have to go into each individual formula and substititue $D$13 for example instead of B1 because this is the position in the data file. What I need is a macro substitution? Can you help me on this? Exactly how I asked in my file.

  27. #27
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,613

    Re: How can I replace a CELL with an IF statement containing that same cell?

    You need to post a better example. You have random cell references in column A, but there is nothing in those cells to track or test so the result in column B is all zeros.
    Ben Van Johnson

  28. #28
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: How can I replace a CELL with an IF statement containing that same cell?

    @polyzp

    Since we are in #27 I think it is usefull if you add an NEW (better explained) small excel file without confidential information.

    Please also add the desired (expected) result in your file.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. If Cell A is equal to Cell B replace the data from Cell A with Cell C. How can I do this.
    By tristanhathaway in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-01-2014, 08:05 PM
  2. Replace cell value based on a logic statement
    By spujr in forum Excel General
    Replies: 5
    Last Post: 01-17-2014, 04:56 PM
  3. [SOLVED] Need help writing macro to replace one cell based on contents of adjacent cell
    By TheRaptMuse in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-24-2012, 12:54 PM
  4. IF Statement: Replace Cell with True Value
    By firehousetk in forum Excel General
    Replies: 5
    Last Post: 11-01-2011, 04:44 PM
  5. Macro To Replace Cell Link With If Statement To Hide Zeros
    By CVinje in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-24-2009, 08:34 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1