+ Reply to Thread
Results 1 to 11 of 11

Swap word in a sentence with input from a textbox or a drop down

  1. #1
    Registered User
    Join Date
    10-13-2018
    Location
    Cheshire, England
    MS-Off Ver
    Office 365
    Posts
    6

    Swap word in a sentence with input from a textbox or a drop down

    Hi

    I'm building a model and would like to be able to make it country adaptive. This will allow the user to either be able to select from a drop-down list or type in a textbox. Where ever there is a country name written, the word will be swapped to their selection. How do I do this?

    Thanks

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,837

    Re: Swap word in a sentence with input from a textbox or a drop down

    I don't know if I have a solution for you, but it would make it easier to help if you could attach a copy of your file with a detailed explanation of what you want to do referring to specific cells, rows, columns and sheets.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    10-13-2018
    Location
    Cheshire, England
    MS-Off Ver
    Office 365
    Posts
    6

    Re: Swap word in a sentence with input from a textbox or a drop down

    Hi

    Thanks for coming back to me.Country change.JPG

    So where I have typed in France, I would like it to replace where it says United Kingdom. B4 has a sentence whilst B6 is a cell that simply says United Kingdom.

    I hope this gives a better explanation.

    Thanks

    Stevie :-)

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,837

    Re: Swap word in a sentence with input from a textbox or a drop down

    You have attached a picture which I cannot access. Please attach a copy of your file. Click the "Go Advanced" button at the lower right. Then scroll down a bit and click "Manage Attachments".

  5. #5
    Registered User
    Join Date
    10-13-2018
    Location
    Cheshire, England
    MS-Off Ver
    Office 365
    Posts
    6

    Re: Swap word in a sentence with input from a textbox or a drop down

    I have uploaded the attachment
    Attached Files Attached Files

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Swap word in a sentence with input from a textbox or a drop down

    You could put this in the sheet's code module.
    Or you could just use Excel's existing Replace dialog box instead of introducing your own control.
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  7. #7
    Registered User
    Join Date
    10-13-2018
    Location
    Cheshire, England
    MS-Off Ver
    Office 365
    Posts
    6

    Re: Swap word in a sentence with input from a textbox or a drop down

    Hi Mike

    Thanks for this. I'm a VBA complete novice. Does this code know to pick out where the country would be in a sentence? I don't understand what each line does for the code.

    Thanks

    Stevie

  8. #8
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Swap word in a sentence with input from a textbox or a drop down

    What happened when you tried it?

  9. #9
    Registered User
    Join Date
    10-13-2018
    Location
    Cheshire, England
    MS-Off Ver
    Office 365
    Posts
    6

    Re: Swap word in a sentence with input from a textbox or a drop down

    I tried out the code and it changes everything in A1:B6 to whatever is typed in the textbox. It doesn't actually change it in cells B4 and B6. It just deletes the U's in "United Kingdom" instead.

  10. #10
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Swap word in a sentence with input from a textbox or a drop down

    You've mentioned that you have no VBA experience.
    The attached uses no VBA, only native Excel that is cross platform from Windows to Mac.

    Column A has the list of possible countries. Add to it as you need.
    The cell B1 has data validation set so the user can only choose from the list of possible countries.
    Column D has the template text, where you type what you want except you enter [country] where you want the country name to be.
    Column F has the final result, where the selected country has replaced [country] from the template text.

    Note:
    1) the use of a dynamic named range to include additions to your list of possible countries.

    2) the result column has formulas that need to be copied down to include all of the rows of the template text column.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    10-13-2018
    Location
    Cheshire, England
    MS-Off Ver
    Office 365
    Posts
    6

    Re: Swap word in a sentence with input from a textbox or a drop down

    Thank you. I will try this :-)

+ 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: 15
    Last Post: 01-30-2018, 09:13 AM
  2. how to input a 2nd drop down based on 1st drop down in a word template
    By excelhelpseeker in forum Word Formatting & General
    Replies: 1
    Last Post: 02-09-2015, 09:14 PM
  3. [SOLVED] How to: Extract everything after the first word in a sentence
    By Teblol in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-05-2014, 01:41 PM
  4. [SOLVED] Option buttons to prduce a sentence into textbox
    By molesy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-31-2014, 08:52 AM
  5. Replace word in a sentence
    By dmarop in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-14-2014, 02:50 PM
  6. [SOLVED] Seeing if a sentence contains a certain word
    By ohaganli in forum Excel General
    Replies: 8
    Last Post: 10-17-2012, 08:27 AM
  7. Find word in sentence
    By WCE_123 in forum Excel General
    Replies: 2
    Last Post: 09-21-2011, 06:59 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