+ Reply to Thread
Results 1 to 4 of 4

Comparing text strings

  1. #1
    Registered User
    Join Date
    11-22-2011
    Location
    Noida
    MS-Off Ver
    Microsoft 365 MSO (16.0.13......) 32 bit
    Posts
    40

    Question Comparing text strings

    I have to do a simple operation from macro that it compares text in three columns and gives results using following logic in adjacent column :-

    Column --> G H I ---> J
    FC FC FC ---> FC
    NC NC NC ---> NC
    Else

    result in J should be PC.

    Also, if F = FC, color cell with Green, If F=NC, color cell Red and else if its PC color cell Blue.
    I tried to write a code and but while compilation it shows some error. I think there is some error in the code lines where I have applied "And" operation.
    Could any one help me in correcting the code.

    Thanks is advance !!

    Please Login or Register  to view this content.
    Last edited by gmalpani; 12-19-2011 at 05:58 AM.

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Help required in correcting the macro for comparing text strings

    The code you've supplied produces a Next Without For error
    Put a Next after the EndWith

    Also try this in your IF...ANDs...
    seems to work

    Please Login or Register  to view this content.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Registered User
    Join Date
    11-22-2011
    Location
    Noida
    MS-Off Ver
    Microsoft 365 MSO (16.0.13......) 32 bit
    Posts
    40

    Re: Help required in correcting the macro for comparing text strings

    Hi Special-K,

    Thanks for your reply !!

    I am facing one more challenge here, if one of the cell is empty then the results are PC.
    For e.g. in column G, I don't have any value as the compliancy is not applicable for this product but in other two product compliancy is provided.

    Illustration:
    Column G --- no value
    Column H --- FC
    Column I --- FC

    Then, G should be ignored and only H and I should be compared.

    Can you give me a hint, what could be the most optimized logic for this. Also, do we have any Compare function in VBA.

    Br,
    gmalpani

  4. #4
    Registered User
    Join Date
    11-22-2011
    Location
    Noida
    MS-Off Ver
    Microsoft 365 MSO (16.0.13......) 32 bit
    Posts
    40

    Question Re: Help required in correcting the macro for comparing text strings

    Hi,

    Meanwhile I was trying to write a code and somehow end up with desired results.
    But as my logic is not very strong, I end up with too many lines of codes.
    Below is the code. Could some1 suggest me the more optimized code for the same. I have attached a file as well for your reference.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by gmalpani; 12-18-2011 at 02:00 PM. Reason: formatting

+ 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