+ Reply to Thread
Results 1 to 8 of 8

VBA Macro for string check

  1. #1
    Registered User
    Join Date
    02-24-2017
    Location
    France
    MS-Off Ver
    2007
    Posts
    86

    VBA Macro for string check

    Hello, I would like to create a macro, which will will check whether the country in col B is different from country in column C and provide for instance 1 in col D in case of condition being true, based on the format below:
    1234567890.PNG
    I'd appreciate some help. Thanks.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: VBA Macro for string check

    In D2 cell

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Drag the above formula down.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    02-24-2017
    Location
    France
    MS-Off Ver
    2007
    Posts
    86

    Re: VBA Macro for string check

    Hello Sixthsense , many thanks for your support, however I am afraid that formula is not working as I have the following output (that's only 1 example):
    66666.PNG
    In column C there is Mauritius, which is different than India in col B, so it should be treated as a match.

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: VBA Macro for string check

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  5. #5
    Registered User
    Join Date
    02-24-2017
    Location
    France
    MS-Off Ver
    2007
    Posts
    86

    Re: VBA Macro for string check

    Please find the spreadsheet attached. I have put the desired output in col D - for each country in col C, which is different from col B there will be 1.
    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: VBA Macro for string check

    You have a variety of white space characters at the end of the column C values.

    This formula should do what you want
    =SIGN(LEN(SUBSTITUTE(CLEAN(UPPER(C2))&";",UPPER(CLEAN(B2))&";","")))
    _
    ...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
    02-24-2017
    Location
    France
    MS-Off Ver
    2007
    Posts
    86

    Re: VBA Macro for string check

    Thank you mikerickson, it's precisely what I have been looking for.

  8. #8
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: VBA Macro for string check

    Quote Originally Posted by mikerickson View Post
    You have a variety of white space characters at the end of the column C values
    Yes it's true, and the macros didn't work out correctly, but you can "bizzarofen" also in that way with macro
    Attached Files Attached Files

+ 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. Check for String and sum up rows where string is equal
    By Rasmus7700 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-18-2017, 04:07 AM
  2. [SOLVED] How to check if a file contains a string?
    By niuyuer in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-08-2016, 01:23 PM
  3. Replies: 7
    Last Post: 04-15-2015, 09:32 AM
  4. Replies: 2
    Last Post: 12-12-2012, 04:19 AM
  5. Replies: 8
    Last Post: 09-27-2012, 10:46 PM
  6. How to check if text is within a string
    By jason_kelly in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-17-2010, 03:35 AM
  7. Macro to check for blank cell entry, copy previous value, and check for duplicates
    By xPunxNotDeadx in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-26-2009, 06:33 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