+ Reply to Thread
Results 1 to 6 of 6

VBA : conditional based on text

  1. #1
    Registered User
    Join Date
    06-20-2014
    Location
    Houston, TX
    MS-Off Ver
    Office 365
    Posts
    47

    VBA : conditional based on text

    Hello,

    I'd like to have VBA code that inputs a single formula that I can copy down to the last row. the amount of rows will always vary. the conditional would check for the words "passenger list" in column C. if this text is found, then one sentence would be constructed from text in other columns. if this text is not found, then a different sentence would be constructed; again with text from the other columns. the attached excel file shows the desired outcome in column Q.

    I've done something similar before where an exact match is looked for; but haven't figured out how to do this with a "contain" type conditional. any help would be appreciated. I hope this all makes sense. I'll provide more context if necessary.

    I've pasted below (first code) some code I've used in the past that has been successful (actually more complicated in that it has nested conditionals); but again with an exact match. I provide this just to show what I'm used to (yeah, I'm a hack and it's not pretty, but it works); but I'm open to whatever formula might be provided.

    Please Login or Register  to view this content.
    this 2nd code is my rather feeble attempt to do what I'm looking for.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by wingfield65; 03-22-2022 at 04:36 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: VBA : conditional based on text

    Fast answers need visual help. Please read the yellow banner at the top of this page on how to attach a file.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    06-20-2014
    Location
    Houston, TX
    MS-Off Ver
    Office 365
    Posts
    47

    Re: VBA : conditional based on text

    Trevor - sorry about that. I forgot. the attachment is there now.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: VBA : conditional based on text

    Try this:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-20-2014
    Location
    Houston, TX
    MS-Off Ver
    Office 365
    Posts
    47

    Re: VBA : conditional based on text

    Trevor,

    Brilliant! Thank you so much. exactly what I was looking for.

    Best Regards,

    David

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: VBA : conditional based on text

    You're welcome.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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. conditional formatting fill cells based on text, how to find sum based on CF colour
    By tubbybear in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-27-2016, 12:04 PM
  2. [SOLVED] Conditional formating based on text in 2 columns (but only partial text!)
    By Icehockey44 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-19-2012, 06:26 AM
  3. conditional formatting row based on text
    By lpratt in forum Excel General
    Replies: 5
    Last Post: 02-01-2011, 08:49 PM
  4. Conditional Formatting based on Text
    By avidcat in forum Excel General
    Replies: 3
    Last Post: 12-31-2010, 07:11 AM
  5. Conditional formating based on text
    By mango7 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-08-2006, 06:11 PM
  6. [SOLVED] Conditional Formatting based on Text within Text
    By George Lynch in forum Excel General
    Replies: 3
    Last Post: 05-05-2005, 03:06 PM
  7. Conditional formatting based on text
    By Gilles Desjardins in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 02-18-2005, 10:06 AM

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