+ Reply to Thread
Results 1 to 12 of 12

If NOT Error

  1. #1
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    If NOT Error

    I have a macro which looks for a certain word. If it finds the word it deletes all rows above it. If it does not find the word I have it to go to ErrorHandle which calls a macro that looks for a different word to find. I want it so that if the macro finds the word and deletes the rows above it that it calls an entirely different macro, and therefore doesn't have to go through the other macros looking for various words. Possible?
    Last edited by ScabbyDog; 03-19-2013 at 05:30 PM. Reason: Re-worded to make it easier to understand

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

    Re: If NOT Error

    Sure. After you run the line of code that deletes the rows, call the other macro then exit the sub. If you were to supply your code we could give you an exact answer.

  3. #3
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: If NOT Error

    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: If NOT Error

    Thanks! Will test now.
    Last edited by ScabbyDog; 03-19-2013 at 07:54 PM. Reason: not solved

  5. #5
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,598

    Re: If NOT Error

    Please Login or Register  to view this content.
    Ben Van Johnson

  6. #6
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: If NOT Error

    Thanks proton. How would I adjust my code above to make it work? I think I'm hitting a snag or two.

  7. #7
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: If NOT Error

    Would it be this then?


    Please Login or Register  to view this content.

  8. #8
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,598

    Re: If NOT Error

    Please Login or Register  to view this content.
    Last edited by protonLeah; 03-19-2013 at 06:38 PM.

  9. #9
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: If NOT Error

    If it doesnt find the word I want it to call test2. If it fimds the word and deletes it I want to call macro3. What you have above does not do that

  10. #10
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,598

    Re: If NOT Error

    Well, we are just guessing at what your code looks like. I just used "test2" because you used that in post #7. In the code posted in #8 note that I changed the variable type to Variant vs. Range.

    The SET line will try to find *interest*; if it does, the variable is set to the range where the item was found, if *interest* is not RngFind is set to "NOTHING".
    Notice RngFind can be either NOTHING or the location where the data was found. To test for a FOUND condition use:
    If Not rngFind Is Nothing Then

    The code in the If..Then block only executes if the value is found, else it does nothing at all. Thus if macro 3 is to be run when found simply replace test2 with macro3.

    Now, if you want to execute an alternative macro when *interest* is not found, just add an ELSE block, thus:
    Please Login or Register  to view this content.

  11. #11
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: If NOT Error

    Thanks Pronto! Works just as I want now. How would I finally adjust your code so it only searches the first 70 rows?

  12. #12
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,598

    Re: If NOT Error

    The quickest way, use:
    Please Login or Register  to view this content.
    I don't know which columns you actually want to search; I just used all cells from A1 down to Z70 as an example.

+ 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