+ Reply to Thread
Results 1 to 24 of 24

Adding a text

  1. #1
    Registered User
    Join Date
    12-09-2012
    Location
    Warsaw
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    44

    Adding a text

    Hello,
    could you please help me to write the appropriate formula to add some text (string value) into each cell of
    a column C in case the following condition is fulfilled: if there is "WER_DANE", than there should be added ";POBR_DANE".

    Thank you in advance.
    Attached Files Attached Files

  2. #2
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,503

    Re: Adding a text

    do you mean something like this... =IF(C2="wer_dane","WER_DANE;POBR_DANE",C2)

    EDIT: this would also do the trick... =IF(C2="wer_dane",C2&";POBR_DANE",C2)
    Last edited by Sam Capricci; 05-20-2016 at 04:50 AM. Reason: alternative formula
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  3. #3
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,065

    Re: Adding a text

    Why not simply SUBSTITUTE?

    =SUBSTITUTE(C2,"WER_DANE","WER_DANE;POBR_DANE")
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  4. #4
    Registered User
    Join Date
    12-09-2012
    Location
    Warsaw
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    44

    Re: Adding a text

    Yes, it works, but how to add new string value, when there are different values in the cells (C2 and C4)?
    Attached Files Attached Files

  5. #5
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,503

    Re: Adding a text

    how about this... =IFERROR(IF(RIGHT(C2,SEARCH(";wer_dane",C2)-2)=";wer_dane",C2&";POBR_DANE"),C2)

  6. #6
    Registered User
    Join Date
    10-12-2013
    Location
    Seattle, USA
    MS-Off Ver
    Excel 2011 for Mac
    Posts
    36

    Re: Adding a text

    Slightly simpler:
    =IF(ISERROR(SEARCH("WER_DANE", C2)),C2,C2&";POBR_DANE")

    In plain English: search in C2 for "WER_DANE". If not found ("ISERROR"), just put the existing contents of C2 in this cell. Otherwise, put in this cell the existing C2, with ";POBR_DANE" added at the end.

    Note that none of these suggested solutions actually change what's in Column C: they just show the result in whatever column you put the formula in. To make the result appear right next to the names as shown in your sample, you'd put the formula in Col D and hide Column C.
    Last edited by ianpage; 05-20-2016 at 04:24 PM.

  7. #7
    Registered User
    Join Date
    12-09-2012
    Location
    Warsaw
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    44

    Re: Adding a text

    Hello Sambo,
    it is almost correct solution, but there is one problem- using this formula causes that "POBR_DANE" is added always to the cell, together with the existing values.
    The expected result is that "POBR_DANE" is added only to these values, which has "WER_DANE" value (See F4 and G4).
    Attached Files Attached Files

  8. #8
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,503

    Re: Adding a text

    I'm looking at F4 and G4 and the formula I gave you in post #5 isn't the formula you have in column G. I pasted my formula in again and it appears to give you what you want. I pasted my formula in cells F7, F8 and F9 and did a simple equal test. If the results you want are in F3, F4 and F5 my formula appears to give you what you want. See your sheet attached.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    12-09-2012
    Location
    Warsaw
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    44

    Re: Adding a text

    Yes, now it is perfect. I've got one more question to you: why do you use in function SZUKAJ.TEKST the value -2. How should it be interpreted?

  10. #10
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,503

    Re: Adding a text

    I'm assuming that this "SZUKAJ.TEKST" either means right or search that are in the formula. The item you are looking for "WER_DANE" appears at different locations in your sheet so looking left wasn't a good option. So I used search. Search for ";WER_DANE" returned 11 for your first location it found it (cell C2) So simple =Search(";WER_DANE",C2) will return 11. Then going in from the right since it appears to be the last part of the cell you want, if you add the Right to that formula, ";WER_DANE" is 9 in length. 11 - 9 is 2, so I had to go back 2 spaces to pull out the ";WER_DANE" part. Since that is what I'm looking for in the if function that is what I needed it to find.
    Hope that makes sense. If not, try sections of the formula building it from the Search out and you'll see.

  11. #11
    Registered User
    Join Date
    12-09-2012
    Location
    Warsaw
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    44

    Re: Adding a text

    Yes, now I understand it. But what could be done if there will be different number of letters before "WER_DANE",so f.eg. instead of YOUNG_DANE(C4), there will be YOUNGU_DANE.
    In such a case, the function you proposed would not be correct...
    Could you maybe please find another solution for such cases?

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

    Re: Adding a text

    You could use the joker sign * in the search formula.
    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.

  13. #13
    Registered User
    Join Date
    12-09-2012
    Location
    Warsaw
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    44

    Re: Adding a text

    Hmm...could you please tell me where it should be exaclty put in the formula
    =JEŻELI.BŁĄD(JEŻELI(PRAWY(C2;SZUKAJ.TEKST(";wer_dane";C2)-2)=";wer_dane";C2&";POBR_DANE");C2)?

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

    Re: Adding a text

    show the file and add manualy the expected result in your file.

  15. #15
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,503

    Re: Adding a text

    Per your post #11, in my formula it doesn't matter how many numbers in it has to go to find the ";WER_DANE" as long as that is the last part it is looking for. So in other words, it has to be the part at the far right of the cell. So it could begin in the 25th position and the formula would still work as long as it is the last part of the cell.

  16. #16
    Registered User
    Join Date
    12-09-2012
    Location
    Warsaw
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    44

    Re: Adding a text

    Please see the cell F9. Could you please write the correct formula in the Excel sheet.
    Attached Files Attached Files

  17. #17
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,503

    Re: Adding a text

    if ";WER_DANE" is always on the right, use this in instead... =IF(RIGHT(C2,9)=";wer_dane",C2&";POBR_DANE",C2)
    this will work.

  18. #18
    Registered User
    Join Date
    12-09-2012
    Location
    Warsaw
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    44

    Re: Adding a text

    Please see the cell F9. Could you please write the correct formula in the Excel sheet.
    Attached Files Attached Files

  19. #19
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,503

    Re: Adding a text

    see the attached sheet with the formula I posted in post #17.
    Attached Files Attached Files

  20. #20
    Registered User
    Join Date
    12-09-2012
    Location
    Warsaw
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    44

    Re: Adding a text

    Thank you very, very much )

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

    Re: Adding a text

    maybe like this, see the green cell.

  22. #22
    Registered User
    Join Date
    12-09-2012
    Location
    Warsaw
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    44

    Re: Adding a text

    It is also good, thank you

  23. #23
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,503

    Re: Adding a text

    You're welcome! And if that solves your issue please don't forget to mark the post as solved using the thread tools dropdown at the top of the post. And if you are so inclined you can click on "* Add Reputation" at the bottom of my post to add to my reputation, it is how we advance on this forum.

  24. #24
    Registered User
    Join Date
    10-12-2013
    Location
    Seattle, USA
    MS-Off Ver
    Excel 2011 for Mac
    Posts
    36

    Re: Adding a text

    I hate to interrupt, but MalgosiaMen, did you check out my proposal in post #6? I believe it does precisely what you wanted, no matter where "WER_DANE" is in the cell. If not, I'll try to help more if you explain why it's not doing what you need...

+ 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. Adding same text at the end of each line on external text files
    By Loski in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-11-2016, 05:49 AM
  2. Adding Multiple Selected Option Text to a common Text Box.
    By venkcris in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-05-2014, 11:15 PM
  3. [SOLVED] adding text in front of potentially existing text (in 1 cell) with IF/THEN statement
    By Marijke in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-10-2014, 04:20 AM
  4. Macro for adding text, spacing, and a replace in a text string.
    By scapegoat9595 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-17-2013, 10:44 AM
  5. Adding text to the start and end of a cells text in another cell
    By kubelwagon in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 11-29-2013, 06:36 PM
  6. Change date into text if <today and adding text if cell isblank... into an Array.
    By JasonNeedsHelp in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-29-2013, 12:06 PM

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