+ Reply to Thread
Results 1 to 23 of 23

For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another column

  1. #1
    Registered User
    Join Date
    08-10-2015
    Location
    Chicago, IL, USA
    MS-Off Ver
    2013
    Posts
    33

    For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another column

    I have an "=IF" test for cells in the first column. When the result is "XYZ", I need to fill "XYZ" in a new cell of a second column. Otherwise do nothing. When another one of the cells tests "XYZ", fill the cell on the next row of the second column with "XYZ". How can I do that?
    Last edited by dazimon; 05-29-2018 at 02:35 PM.

  2. #2
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another colum

    please attach a sample worksheet and expected result.

    To attach a file to your post: (Please no pics or screenshots ... saves retyping data.),


    •be sure to desensitize the data
    •click “Go Advanced” (next to Post Quick Reply – bottom right),
    •scroll down until you see “Manage Attachments”, click that,
    •click “Browse”.
    •select your file(s)
    •click “Upload”
    •click “Close window”
    •click “Submit Reply”

    The file name will appear at the bottom of your reply.
    1. Click on the * Add Reputation if you think this helped you
    2. Mark your thread as SOLVED when question is resolved

    Modytrane

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another colum

    Your description can be interpreted in more than one way. Please attach a file with sample data showing what kind of result you want.

    I have an "=IF" test for cells in the first column.
    Does this mean that the =IF formula appears in the first column, or that the cells it is testing appear in the first column?

    When the result is "XYZ"
    Do you mean the result of the IF formula is "XYZ"? Or the value of the cell it is checking is "XYZ"?

    fill the cell on the next row of the second column with "XYZ"
    What is the value of just having a list of cells that all say "XYZ", the same number of times that "XYZ" appears in the other column?

    With these assumptions:
    1. Your IF formula is in column A
    2. The result of your IF formula can be "XYZ"
    3. You want your results in column B
    4. Row 1 contains headers and your data starts in row 2


    This formula in the second column will add an "XYZ" in the next cell every time a new XYZ appears in column A. You must extend this formula down for as many rows necessary. Put in B2 and copy down.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Registered User
    Join Date
    08-10-2015
    Location
    Chicago, IL, USA
    MS-Off Ver
    2013
    Posts
    33

    Re: For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another colum

    6StringJazzer,

    Thanks for you quick response! I realize it is a bit more complicate because the "XYZ" is a result of a function. That's why, as suggested by modytrane, I will upload a test sheet.

  5. #5
    Registered User
    Join Date
    08-10-2015
    Location
    Chicago, IL, USA
    MS-Off Ver
    2013
    Posts
    33

    Re: For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another colum

    modytrane,

    I very much appreciate your suggestion and your precious time devoted to helping me.
    Attached Files Attached Files

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another colum

    Quote Originally Posted by dazimon View Post
    [...]"XYZ" is a result of a function.
    Doesn't matter. Solution with my formula attached.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    08-10-2015
    Location
    Chicago, IL, USA
    MS-Off Ver
    2013
    Posts
    33

    Re: For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another colum

    OK. Let me throw another monkey wrench into the works. I actually need for the result of the formula to appear in the next available cell in column "K", but I do not know what it will be. That is because it will be applied to several sheets, each one of different value, a result of concatenation in column "J". See the updated Test Sheet.

    Is it possible using functions, arrays, VB? Thanks!
    Attached Files Attached Files
    Last edited by dazimon; 05-30-2018 at 02:02 PM.

  8. #8
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another colum

    I don't understand what your latest description means. The essential problem is still the same.

    Your file actually has "XY Z" with a space, so my formula needs to be changed. There is also no header, so the "-1" must be removed. Here is the result.

    If this is not what you want, then you are going to need to show an example of the result you want.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    08-10-2015
    Location
    Chicago, IL, USA
    MS-Off Ver
    2013
    Posts
    33

    Re: For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another colum

    Thank you for your patience. The results I need are in column "L" now.
    Attached Files Attached Files

  10. #10
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another colum

    That is much clearer. There is a way to do that but I will have to look it up.

    By the way, it is quite different than the question you posted. The whole XYZ reference seems to be a red herring. I think your question is more like this:
    Create a column that lists all of the results from another column, skipping any blank results.

  11. #11
    Registered User
    Join Date
    08-10-2015
    Location
    Chicago, IL, USA
    MS-Off Ver
    2013
    Posts
    33

    Re: For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another colum

    You are correct. Not being a programmer, I didn't pose the question right. To add to the way you formulated my need, "list only one instance of the result of concatenation for each 'XY Z', 'AB C', etc.", as shown in column "L". Once again, I appreciate your patience and time you're taking to help me.

  12. #12
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another colum

    OK, here is a formula solution that uses an array formula. However, it can't start in row 1. So I created one column with the result starting in row 2, and then another column that references the solution one row down, so it starts in row 1. You can hide the "helper" column if you don't want it to show.

    I am assuming that this is exactly how your real file is laid out except for the data.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    08-10-2015
    Location
    Chicago, IL, USA
    MS-Off Ver
    2013
    Posts
    33

    Re: For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another colum

    6StringJazzer,

    Thank you very much! That'll work.

    Now I have your code and can play with it an learn a bit. The real spreadsheet has 14 sheets like the one I shared. It will be fun to see whether I'll manage learn and place results of your code from each sheet into one column on sheet #15 or have to use 14 columns which would be easier. I could use the 14 columns as helping columns to feed the one column with results from all the sheets.

    Once again, thank you very much for having spend the time to help me.
    Last edited by dazimon; 05-31-2018 at 02:01 PM.

  14. #14
    Registered User
    Join Date
    08-10-2015
    Location
    Chicago, IL, USA
    MS-Off Ver
    2013
    Posts
    33

    Re: For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another colum

    I did find a little time to try and place results of your code (used on the "Original" sheet of the attached test spreadsheet) from each sheet (1-5) into one column on another sheet ("New Tally").

    I encountered two unwanted phenomena:
    1. Unlike in your solution in the "Original" sheet, when the code in the "New Tally" column A finds no missing Approved date in column H of the sheet it looks the data up in, the cell in column A on "New Tally" sheet displays "0" or remains empty. It doesn't get filled with the results of the first next line calculation that reflects the fact an Approved date is missing on one of the five sheets. I presume it is because each row refers to different sheet data. Is there a way to overcome this shortcoming?
    2. The first instance of a sheet (1-5) that has no missing Approved date, produces "0" in the corresponding cell in column A on "New Tally" sheet. Each additional instance produces an empty cell. Is there a way to make replace the "0" with empty cell?
    Attached Files Attached Files

  15. #15
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,594

    Re: For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another colum

    Here's a low tech offering:
    Use what you have so far on the 'New Tally' sheet (with some minor modifications) as a helper column, perhaps move it to column XFD or hide it if you don't want anyone else to know that it is there. Then populate cells A2:A7 using*:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    *Denotes an array entered formula which needs to be confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula.
    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  16. #16
    Registered User
    Join Date
    08-10-2015
    Location
    Chicago, IL, USA
    MS-Off Ver
    2013
    Posts
    33

    Re: For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another colum

    JeteMc,

    low tech is fine with me. I appreciate your putting in the time to make it work. You solved my challenge of tallying data from multiple sheets. Thank you!

    Well, I found out that after yet another enhancement to the spreadsheet, there's one more issue. If there are several items in column "J", only the first one surfaces in the "New Tally" sheet.

    To demonstrate, I implemented the enhancement on Sheet 1. (The value from "C" is added to the concatenation statement, because there are two types of items, "QA" and "SA". I need each item that still needs approval to show up in "New Tally", because even if they're of the same type, they are specific, unique items.
    Attached Files Attached Files

  17. #17
    Registered User
    Join Date
    08-10-2015
    Location
    Chicago, IL, USA
    MS-Off Ver
    2013
    Posts
    33

    Re: For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another colum

    Duplicate posting. Content deleted.
    Last edited by dazimon; 07-05-2018 at 01:29 PM. Reason: duplicate posting

  18. #18
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,594

    Re: For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another colum

    "low tech is fine with me."
    Good to hear because there is more of it in this proposal.
    Cells XEV1:XEZ1 are populated with Sheet1, Sheet2 ...
    Cells XEV2:XEZ5 are populated using*:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Cells XFD2:XFD20 are populated using*:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Cells A2:A20 are populated using*:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    *Denotes array entered formula as discussed in post #15.
    Let us know if you have any questions.
    Attached Files Attached Files

  19. #19
    Registered User
    Join Date
    08-10-2015
    Location
    Chicago, IL, USA
    MS-Off Ver
    2013
    Posts
    33

    Re: For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another colum

    JeteMc,

    Thank you very much. It is working like a charm. :-)

    The only glitch in the real spreadsheet that I applied the solution to is that a couple of times the column "A" in the "New Tally" sheet will include not only the proper results, but one or several empty rows. What type of phenomena in would lead to that occurring? (I took care of zeroes showing up, but even after close examination of data and patterns can't figure out what causes the empty cells in the "New Tally" column "A".)

  20. #20
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,594

    Re: For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another colum

    I don't remember any zeroes showing up. When you say "took care of" do you mean something like hiding them with conditional formatting? If so the formula will still pick that up. Other than that I would really need to see a sample of the data that is causing the problem.
    Sorry not to be of more help.

  21. #21
    Registered User
    Join Date
    08-10-2015
    Location
    Chicago, IL, USA
    MS-Off Ver
    2013
    Posts
    33

    Re: For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another colum

    The zeros occurred because I have additional sheets in the real spreadsheet in which I had not yet included the formulas. So you never saw this problem and on my end I've fixed by inserting your formula.

    The remaining issue is just the empty rows at certain points of the column "A". Not being a programmer, I just use Excel help, this forum and detecting patterns to figure things on the rare occasion I program a spreadsheet.

    I know I'm repeating myself, but given the formula,

    =IFERROR(INDEX(XFD$2:XFD$20,SMALL(IF(XFD$2:XFD$20<>"",ROW($2:$20)-1),ROW(1:1))),"")

    what condition would make it insert an empty row(s)?

    Thank you!

  22. #22
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,594

    Re: For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another colum

    I have tried some scenarios but I could not replicate an instance where the formula would display empty rows between rows of proper results. If you are not able to upload a sample that shows the issue, then perhaps selecting one of the empty cells and using the Evaluate Formula feature will give a hint as to the cause.

  23. #23
    Registered User
    Join Date
    08-10-2015
    Location
    Chicago, IL, USA
    MS-Off Ver
    2013
    Posts
    33

    Re: For each cell that tests "XYZ" in one column, add "XYZ" in a new cell of another colum

    Thanks. That issues has fallen of the priority list for the time being. :-)

+ 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. Replies: 6
    Last Post: 07-16-2017, 09:06 AM
  2. [SOLVED] Column X-Ref list - Sheet1 Col A "pages", Col B:FL "Req" to Sheet2 ColA "req", ColB "page"
    By excel-card-pulled in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-07-2017, 09:30 AM
  3. [SOLVED] filling cell in column "a" if data present in column "b" issue.
    By timmatthews in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-07-2013, 11:43 AM
  4. [SOLVED] If there is any text in column "A$" on "sheet1" then move cell to column "A$" on "sheet2"
    By ckgeary in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-27-2013, 08:28 PM
  5. Replies: 2
    Last Post: 06-06-2013, 12:45 PM
  6. Replies: 9
    Last Post: 11-06-2012, 08:59 AM
  7. [SOLVED] Delete row if cell in Column N equal "Different" or Column P equals "Blank"
    By Cyberpawz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-17-2012, 08:25 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