+ Reply to Thread
Results 1 to 9 of 9

If Statement?

  1. #1
    Forum Contributor
    Join Date
    03-07-2013
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    274

    If Statement?

    Hello,

    I am trying to test the contents of a cell as to weather it contains an "X" or not with an if statement.

    At the "If" line I get error 400???

    here is the code:

    See attachment


    Thanks so much for your help
    RN
    Attached Files Attached Files
    Last edited by RustyNail; 02-19-2018 at 01:04 PM.

  2. #2
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,734

    Re: If Statement?

    =if( cell = "X" , "contains X", "does not contain X")

    where cell is the address of the cell you want to test
    ie A2 , B3 etc
    Wayne
    if my assistance has helped, and only if you wish to , there is an "* Add Reputation" on the left hand side - you can add to my reputation here

    If you have a solution to your thread - Please mark your thread solved do the following: >
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: If Statement?

    Hi,

    Assming you want to see if x occurs in a string of several characters then maybe as a function

    =IF(ISERROR(SEARCH("x",A1)),"","Y")

    You can post code or functions. Just click the # or fx icons above the post area to wrap your code/function in the approriate tags.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Contributor
    Join Date
    03-07-2013
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    274

    Re: If Statement?

    This is frustrating ... the site won't allow me to post sample code


    You can view the code text file to see exactly what I am trying to do!!

    Thank you so much for your help
    Last edited by RustyNail; 02-19-2018 at 01:08 PM.

  5. #5
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,734

    Re: If Statement?

    oh, OK VBA - not my area, should be in VBA forum really
    I'm sure Richard Buttrey , will move

  6. #6
    Forum Contributor
    Join Date
    03-07-2013
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    274

    Re: If Statement?

    I need to put the if statement in a for loop so I need the numbers of the rows...

    Please view my attachment in the initial post !!!

    Thanks

  7. #7
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,734

    Re: If Statement?

    oh, OK VBA - not my area, should be in VBA forum really
    I'm sure Richard Buttrey , will move

    using the >>>>>>> is being seen as HTML code tag

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    03-07-2013
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    274

    Re: If Statement?

    Ok I had the column and row inverted ....

    Solved!


    PS can someone tell me how to mark this thread as solved?

    Thank you

  9. #9
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: If Statement?

    ...and hadn't put the "A" in literals.

    That said why is the macro always selecting the same two B6 & E10 cells wherever an x occurs. It's not at all obvious what a loop is achieving.

+ 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. [SOLVED] i have an if then statement that works, how to make it work as a with or case statement
    By dmcgov in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-03-2016, 03:34 PM
  2. Replies: 2
    Last Post: 07-09-2015, 04:25 PM
  3. compile error expected line number statement end statement
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-18-2014, 10:12 AM
  4. VBA Compile Error : line number or label or statement or end of statement
    By excellearner121 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-04-2013, 06:41 PM
  5. Replies: 4
    Last Post: 06-01-2012, 10:05 AM
  6. Replies: 4
    Last Post: 05-16-2012, 05:33 PM
  7. [SOLVED] Utilize a Select Case Statement in Target Intersect Statement
    By max57 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-29-2009, 08:55 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