+ Reply to Thread
Results 1 to 6 of 6

Criterias for IF Statement

  1. #1
    Registered User
    Join Date
    10-12-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    76

    Criterias for IF Statement

    Hi there

    I've got a line of code where the excel sheet creates a report by picking up certain values from the cell

    One of the code is as follows

    If (strGroup Like "Computers*") Then
    GiveTo = "Youngsters"

    where Youngsters is a emailgroup created for the report

    I want to add certain extra things to this strTask Like "Help*" Then GiveTo = "Volunteers"

    Can anyone help me so that my code will search if strGroup and StrTrask match then only will it GiveTo Volunteers. If only StrGroup match then it should give to Youngsters for which i my above code works fine

    regards
    Last edited by captedgar; 01-13-2010 at 02:14 PM.

  2. #2
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    649

    Re: Criterias for IF Statement

    Not sure that I am understanding you fully. What about the test
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-12-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    76

    Re: Criterias for IF Statement

    Quote Originally Posted by blane245 View Post
    Not sure that I am understanding you fully. What about the test
    Please Login or Register  to view this content.
    Thanks Blane for the reply
    You got it almost right. I have googled and found out on the help page but cannot understand why the following codes are not working
    If (strGroup Like "Computers*" And strTask Like "Yes") Then GiveTo = "Volunteers"


    If (AND(strGroup Like "Computers*",strTask Like "Yes")) Then GiveTo = "Leads"


    Where strGroup and strTask= These are global variables defined in my code
    Computers = This is a dropdown choice which a user can select
    Yes = This is a cell which is conditionally formatted and gets picked up in the same row when the user select Computer or any other choice from the dropdown list
    Default value of the cell is No
    Volunteers/Leads = I have another function in the section of code which generates an email when user selects the choice from the dropdown list and selects Yes. So, Volunteers/Leads are emailgroups in outlook which gets added to the recipient section in my generated email.

  4. #4
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    649

    Re: Criterias for IF Statement

    Could you post a file with your code and some nonsensitive data, and explain why the code is not working like you want it to? I need more information.

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Criterias for IF Statement

    Remember also that VBA unlike native XL is Case Sensitive by default - so if you wish to make insensitive (and have not done so already) either

    a) add Option Compare Text to head of Module

    b) convert Strings to common case before Comparing, eg:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    10-12-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    76

    Re: Criterias for IF Statement

    Quote Originally Posted by DonkeyOte View Post
    Remember also that VBA unlike native XL is Case Sensitive by default - so if you wish to make insensitive (and have not done so already) either

    a) add Option Compare Text to head of Module

    b) convert Strings to common case before Comparing, eg:

    Please Login or Register  to view this content.
    Thanks Guys

    It's working now due to DonkeyOte's suggestion

    Appreciate your patience in resolving the query

+ 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