+ Reply to Thread
Results 1 to 4 of 4

How do I do incorporate an "if statement" with the ".find" method in a range?

  1. #1
    Forum Contributor
    Join Date
    04-01-2010
    Location
    USA
    MS-Off Ver
    Office 2021
    Posts
    185

    How do I do incorporate an "if statement" with the ".find" method in a range?

    I want to search the selected range for a variable value (calculated previously in the sub) and if it finds the value I want the sub to do some things. If it's not in the range I want it do something else.

    Here is the relevant section for what I have:

    Please Login or Register  to view this content.
    This works and cuts the value I'm looking for if it finds a value in the range. The problem is it's not in the range I don't know how to tell it to follow other instructions. I tried the "iserror" with an in statement, but it said the range was not set. Intellisense isn't working and I don't really know how to use the .find method

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: How do I do incorporate an "if statement" with the ".find" method in a range?

    Please Login or Register  to view this content.
    The above is incorrect. You have not specified a range to find "income" in. You would need to change it to something like this:

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    04-01-2010
    Location
    USA
    MS-Off Ver
    Office 2021
    Posts
    185

    Re: How do I do incorporate an "if statement" with the ".find" method in a range?

    There is no way to tell it to search for the selected range? So I should take out

    Please Login or Register  to view this content.
    and replace it with:

    Please Login or Register  to view this content.
    I tried that and I get a type mismatch error

    Then I can I say something like:

    Please Login or Register  to view this content.
    Quote Originally Posted by stnkynts View Post
    Please Login or Register  to view this content.
    The above is incorrect. You have not specified a range to find "income" in. You would need to change it to something like this:

    Please Login or Register  to view this content.
    Last edited by max3732; 06-22-2014 at 05:16 PM.

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: How do I do incorporate an "if statement" with the ".find" method in a range?

    A range value doesn't return true or false. It is either a range or nothing. To test the validity of .find you would do something like this:

    Please Login or Register  to view this content.
    However, I doubt this will answer your question. The code you supplied is pretty garbled. I would suggest you submit a clearer and precise picture of what you are trying to accomplish and having us rewrite from scratch. Submitting an example workbook with before and after examples will help you get a solution faster.

+ 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. Replies: 3
    Last Post: 04-14-2013, 11:53 PM
  2. "The "sheets" method from the "_Global" object have failed."
    By mankit87 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-08-2011, 08:53 AM
  3. Replies: 3
    Last Post: 12-14-2006, 01:36 PM
  4. Replies: 5
    Last Post: 06-26-2006, 09:23 PM
  5. [SOLVED] What is Error "Method "Paste" of object "_Worksheet" failed?
    By vat in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-17-2006, 04:10 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