+ Reply to Thread
Results 1 to 6 of 6

comment if cell contains a certain text

  1. #1
    Registered User
    Join Date
    07-22-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    85

    comment if cell contains a certain text

    Hi,

    I currently have an auto commenter "ME RELATED" based on if the cell has contents that is below the input date or does not have "CCY". However i want to amend the condition such that it will not comment if the selected cell will CONTAIN CCY somewhere in the cell.
    Thanks for your help


    Please Login or Register  to view this content.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: comment if cell contains a certain text

    Hello kchm_2000,

    You can use the Like operator to check if the cell contains those characters in the cell. I have made the change to the code below.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    07-22-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    85

    Re: comment if cell contains a certain text

    how do you turn off or on the case sensitivity?

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: comment if cell contains a certain text

    Hello kchm_2000,

    The easiest way is to convert the string to either lower case, LCase, or to upeer case, UCase and then compare. See the change in bold.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-22-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    85

    Re: comment if cell contains a certain text

    oh thanks very much, I just have one more query, How do I adjust this formula so that I can present in a case select or if else manner in one sub(). Where for instance have a first criteria in my previous formula below

    Please Login or Register  to view this content.
    and the second one is this

    Please Login or Register  to view this content.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: comment if cell contains a certain text

    Hello kchm_2000,

    There are two ways to accomplish this. The first answer and easiest would be to make each maco operate only on one section. You could then create a macro using a Case statement to call each macro based on some cell value.

    The other method would be to create a Function macro that took arguments and used them in the same loop. This is more complex approach. It can save space and make maintain the code easier. But, it all depends on how similar the routines are.

+ 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