+ Reply to Thread
Results 1 to 7 of 7

Extract specific text in Cell A1 and display in A2

  1. #1
    Registered User
    Join Date
    03-12-2008
    Posts
    76

    Extract specific text in Cell A1 and display in A2

    Good afternoon,

    Can somebody please help me with this problem:

    I Need to extract country codes/names from a paragraph of text from Cell A1 (Worksheet 1) and display in cell A2 (worksheet 2) in a specific format.

    Each time one of our customers does a marketing campaign they fill in an Excel spreadsheet (layed out as a form). There is one cell where they can write a description of their marketing campaign.

    E.g. "We are doing a campaign in France, Germany and possibly in UK"

    From this I need to automatically extract France, Germany, UK and display it in cell A2 as "FR DE UK" ie without commas between country codes.

    So if "France" is found in cell A1 then the country code "FR" needs to be displayed in cell A2. IF "FR" is found in cell A1 then "FR" is displayed in A2.

    Text to find:

    France= FR
    Germany = DE
    United Kingdom = UK
    Spain= ES
    Denmark = DK

    There are more countries, but I can add them myself once I understand the basic code.

    I tried IFERROR, OR and IF statements but this did not work.


    Thanks

    Dave32
    Last edited by Dave32; 07-21-2008 at 09:30 AM.

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    this macro udates A2 when A1 is changed if the macro is installed correctly & macro security is not set to high

    'These instructions pre typed & are worded to cater for the novice programmer
    'To install macro to correct location

    'Copy this macro
    'GoTo Excel
    'Select sheet this is to appy to
    'Right Click on Sheet Name Tab > select View Code
    'Past macro into the Worksheet Module displayed

    Please Login or Register  to view this content.
    or to run macro when you want to try
    Please Login or Register  to view this content.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Or

    Select the cells to check first

    Please Login or Register  to view this content.
    VBA Noob
    Attached Files Attached Files
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  4. #4
    Registered User
    Join Date
    03-12-2008
    Posts
    76

    Extract specific text in Cell A1 and display in A2

    Mudraker,

    Thanks for your help, the first Macro gave an error

    "Complile error End if without block if"

    Regards,

    Dave32

  5. #5
    Registered User
    Join Date
    03-12-2008
    Posts
    76

    Extract specific text in Cell A1 and display in A2

    VBA Noob,

    This does work, but things are more complicated, if need to extract the data from Cell D25 in Worksheet A and put the countries in Cell C9 but in worksheet B. I want to keep all Macros out of worksheet A. So ideally the Macro is stored in worksheet B and there is a button you click on the automatically extract the data and put it all into C9.

    I do not want commas between the country codes either.

    I am a novice, but it appears you used a list box, I do not know where you stored the country codes as I cannot find it in the script.

    I would greatful if you could send me another sample spreadsheet,

    Dave32

  6. #6
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    See if this helps

    VBA Noob
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    In my code I have an End If at the end when it should be End Sub

+ 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