+ Reply to Thread
Results 1 to 5 of 5

If a value is NOT found then call another macro

  1. #1
    Registered User
    Join Date
    07-20-2015
    Location
    New York
    MS-Off Ver
    2305 - Enterprise 365
    Posts
    162

    If a value is NOT found then call another macro

    Hello All,
    I am trying to write some coding which has two outcomes depending on whether a certain value is found or not in an absolute reference region.
    The first scenario is for when the value (in this case "INVOICE NO.") is found. In this case, the macro simply ends.
    The second scenario is for when the value "INVOICE NO." is NOT found. In this case, the macro calls another macro named "Tabulating_overcharges_undercharges_results_part_2".
    The absolute reference region is Range("I8:I33"). Note, however, that the sheet name should NOT be listed. This macro applies to the currently active sheet - whichever active sheet the macro is working on.
    Here is the coding which needs to be fixed. The coding that's not working is in bold:
    Please Login or Register  to view this content.
    Thanking you in advance,
    Andrewstupendo

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

    Re: If a value is NOT found then call another macro

    Please Login or Register  to view this content.
    You didn't specify a sheet to search on....?
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    07-20-2015
    Location
    New York
    MS-Off Ver
    2305 - Enterprise 365
    Posts
    162

    Re: If a value is NOT found then call another macro

    Hello ProtonLeah,
    The coding doesn't seem to be working. If you need an actual worksheet name, let's call it "8.5 x 11".
    I may have left out an important piece of information. It's supposed to select the cell where "INVOICE NO." is located.
    Best.
    Andrewstupendo

  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
    48,488

    Re: If a value is NOT found then call another macro

    Quote Originally Posted by Andrewstupendo View Post
    Hello ProtonLeah,
    The coding doesn't seem to be working. If you need an actual worksheet name, let's call it "8.5 x 11".
    I may have left out an important piece of information. It's supposed to select the cell where "INVOICE NO." is located.
    Best.
    Andrewstupendo
    An actual workbook with typical data, structure and code would be more helpful.

    If you want assistance with your problem, it makes sense for you to help those who want to help you.
    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


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

    Re: If a value is NOT found then call another macro

    Please Login or Register  to view this content.


    In your code, you introduced an undeclared variable, Rng, so VBA created it as type Variant with an initial value of Nothing. You used it without setting it (it has nothing to do with any of the previous code) so it remains Nothing.

+ 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. Call Macro X if the sheet name contains "...", otherwise Call Macro Y
    By antotom98 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-11-2022, 04:19 AM
  2. [SOLVED] Dynamic macro name / Concatenating macro name / Call a string variable as a macro name
    By vwhite in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-18-2020, 03:36 AM
  3. [SOLVED] macro showing error ( macro not found ) while trying to execute macro every 1 minute
    By prabhuduraraj09 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-16-2018, 07:58 PM
  4. Run (Call) Three Other Macros depending on values found
    By Andrewstupendo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-27-2018, 01:29 PM
  5. Replies: 2
    Last Post: 08-13-2014, 06:39 PM
  6. Replies: 1
    Last Post: 08-13-2014, 05:46 PM
  7. Calling macro 10 times, add header list to macro call only once
    By capson in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-05-2013, 09:42 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