+ Reply to Thread
Results 1 to 9 of 9

Seeing if a sentence contains a certain word

  1. #1
    Registered User
    Join Date
    10-16-2012
    Location
    Guelph, Canada
    MS-Off Ver
    Excel 2003
    Posts
    26

    Seeing if a sentence contains a certain word

    Hey everyone, so this is my problem: In excell I have 2 sheets. On the second sheet, the G collum lists phone numbers. For example:

    [B]G
    (519) 555-1234
    (416) 534-8273
    (519) 348-2846

    Im trying to figure out an If statement that says "If a G cell contains
    "(519)" move it to cell A1 in sheet1.

    Thanks for the help, if you need me to be more clear just let me know

  2. #2
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    Excel 2003,2007,2010,2013
    Posts
    1,914

    Re: Seeing if a sentence contains a certain word

    Hi

    One way maybe!
    Just need your sheet reference.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-16-2012
    Location
    Guelph, Canada
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Seeing if a sentence contains a certain word

    Here is the code I was trying. I am VERY new to VB, so its obviously terrible and it doesnt work, but maybe it will show you when i am trying to do

    Please Login or Register  to view this content.
    Last edited by Cutter; 10-17-2012 at 08:25 AM. Reason: Added code tags

  4. #4
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Seeing if a sentence contains a certain word

    Try this small macro:

    Please Login or Register  to view this content.

    Macros are very easy to install and use:

    1. ALT-F11 brings up the VBE window
    2. ALT-I
    ALT-M opens a fresh module
    3. paste the stuff in and close the VBE window

    If you save the workbook, the macro will be saved with it.

    To remove the macro:

    1. bring up the VBE window as above
    2. clear the code out
    3. close the VBE window

    To use the macro from Excel:

    1. ALT-F8
    2. Select the macro
    3. Touch RUN

    To learn more about macros in general, see:

    http://www.mvps.org/dmcritchie/excel/getstarted.htm

    Macros must be enabled for this to work!
    Gary's Student

  5. #5
    Registered User
    Join Date
    10-16-2012
    Location
    Guelph, Canada
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Seeing if a sentence contains a certain word

    Oh, and in that example I am only checking Cell G2, however i want to check every cell in the G collumn

  6. #6
    Registered User
    Join Date
    10-16-2012
    Location
    Guelph, Canada
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Seeing if a sentence contains a certain word

    Wow that worked! :D Thanks so much, you were very helpful and thanks for the quick responses, i needed this ASAP :P

  7. #7
    Registered User
    Join Date
    10-16-2012
    Location
    Guelph, Canada
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Seeing if a sentence contains a certain word

    Sorry one more thing. Which part of your code is telling it to put the numbers in collumn A? Because i want to use the same code to do the exact same thing, except put all the "416" numbers in collumn B

  8. #8
    Registered User
    Join Date
    10-16-2012
    Location
    Guelph, Canada
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Seeing if a sentence contains a certain word

    annnnnd nevermind, i found it :3 lols sorry

  9. #9
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,452

    Re: Seeing if a sentence contains a certain word

    @ ohaganli

    Welcome to the forum.

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    I also added code tags to your post (#3) as per forum rules. Please remember that for your future posts.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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