+ Reply to Thread
Results 1 to 8 of 8

if cell includes string, append a character to the value of another cell.

  1. #1
    Registered User
    Join Date
    02-11-2010
    Location
    Maryland, USA
    MS-Off Ver
    Excel 2007
    Posts
    83

    Question if cell includes string, append a character to the value of another cell.

    Hi guys and gals,

    I need a bit of help from the excel gurus.

    I'd written a formula that would check the value of each cell in a column (P2:...) and if the cell includes specific text ("May 29") it sets the value of another cell (F2:...). Here's what I wrote:
    Please Login or Register  to view this content.
    Now I need to be able to do basically the same thing, only there is already a set of information in the column (F), so I need to append the value to the cell (F2:...) if (P2:...) contains the value that I'm looking for. If P2... doesn't contain the value that I'm looking for, I want to let the value of F2... remain.

    The other kink is that I will likely have to do this again in the future, or have someone else do it, so a macro that will ask me to identify the column to search, the text to find, the target column, and the text to append, would be really really handy.

    I'm working on learning my VBA skills, but this is completely out of my league. Can anyone help me out?

    Thanks!

    Rob

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

    Re: if cell includes string, append a character to the value of another cell.

    You get better help if you post an Excel-example of your workbook, without confidential information.

    Make sure the workbook demonstrates your desired results if possible, or just highlight the cells you're trying to fix.

    Use BEFORE/AFTER sheets if that helps make it clearer.
    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.

  3. #3
    Registered User
    Join Date
    02-11-2010
    Location
    Maryland, USA
    MS-Off Ver
    Excel 2007
    Posts
    83

    Re: if cell includes string, append a character to the value of another cell.

    A fair point Oeldere. Thank you! Teach me to be in a hurry

    Here is an example of the spreadsheet before applying the macro:
    Before Sample.xlsx

    And here is an example of the spreadsheet after applying the macro:
    After Sample.xlsx

    In this example upon executing the macro, I would be prompted with a message box asking me to identify the column to search.
    I selected or entered column H
    A text box would then ask me to enter the word to find. I would enter "April 13,"
    Another message box would then ask me to identify the target column.
    I would select column B
    Finally, a message asks me to enter the text to be appended.
    I would enter "; Armenian"
    the macro would search for the text "April 13," in each cell.
    Finding "April 13," in H2, the macro would append the string "French; German; English" at B2 with the term "; Armenian" to create "French; German; English; Armenian"
    The macro would then move onto H3, and would create "French; Armenian" in B3
    At row 4, the system would just enter "Armenian" (I know, the "; "... just thought of that and don't know how to deal with it. Any brilliant ideas?)
    At row 5, because "April 13," does not appear at H5, B5 remains "Klingon, Unicorn" but no "; Armenian"
    And so on...

    This example brings up another completely different concern. Notice that the person who came before me wasn't very consistent. Sometimes they used ";" and other times they used ",". There are also random carriage returns and extra trailing spaces in different cells. Any idea how to consistently get rid of these?

    Sorry if that is too long and drawn out, or if it put anyone to sleep. I really appreciate the help on this. I'm trying to learn, but like I said, this is way out of my league right now.

    Thanks,
    Rob

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

    Re: if cell includes string, append a character to the value of another cell.

    Before looking ad your examples:

    1) I can't help you enough with VBA.


    Please Login or Register  to view this content.
    2) Work with datavalidation

    3) For the future, you can use the same workbook for the before an after situation.
    You can use differnt worksheets.

    i attach a workbook with the before an after situation.

    Maybe you can point us, where we can find the cells that need to be changed.
    Attached Files Attached Files
    Last edited by oeldere; 06-30-2012 at 04:29 AM.

  5. #5
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: if cell includes string, append a character to the value of another cell.

    Try this,

    Click the button to the right to run.
    Attached Files Attached Files
    Last edited by JapanDave; 06-30-2012 at 04:52 AM.
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: if cell includes string, append a character to the value of another cell.

    You could just use native fumctions and standard Excel features, they are worth learning!

    !/. Add a sheet, I've called it "Before Cleaned"
    In A1
    Please Login or Register  to view this content.
    Drag Across and Down as required
    Copy the result, (not the whole sheet), and Paste Special > Values to
    "Report Language" A2

    Delete Sheets "Before" & "Before Cleaned"

    2/. With "Report Language"
    Insert a column between Columns B:C, this will become Column C, the following columns will increment automatically.

    In A1 put the language you need to add "Armenian"

    In B2 put the text you want to find "April 13", this should be preceded with an apostrophe to avoid Excel forcing a serial date.

    In C3
    Please Login or Register  to view this content.
    Drag/Fill Down as required.

    You can then use Copy > Paste Special > Values and delete columns as you need.

    This takes longer to explain than do!
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: if cell includes string, append a character to the value of another cell.

    Hi robbyvegas
    Try the code in the attached. I believe it addresses these issues
    I would be prompted with a message box asking me to identify the column to search
    ask me to enter the word to find
    ask me to identify the target column
    asks me to enter the text to be appended
    Sometimes they used ";" and other times they used ",". There are also random carriage returns and extra trailing spaces in different cells. Any idea how to consistently get rid of these?
    Let me know of issues.
    Attached Files Attached Files
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  8. #8
    Registered User
    Join Date
    02-11-2010
    Location
    Maryland, USA
    MS-Off Ver
    Excel 2007
    Posts
    83

    Re: if cell includes string, append a character to the value of another cell.

    Quote Originally Posted by JapanDave View Post
    Try this,

    Click the button to the right to run.
    You guys ROCK! Sorry, I haven't had a chance to check in since I lots power on Fri. night. My house is still without power... Argh...

    I'll try these solutions now.

    Thanks again!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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