+ Reply to Thread
Results 1 to 4 of 4

VBA - If value not found, skip part of macro.

  1. #1
    Registered User
    Join Date
    05-23-2013
    Location
    Iowa
    MS-Off Ver
    Excel 2007
    Posts
    84

    VBA - If value not found, skip part of macro.

    Hi all,

    What I'm looking to do:

    -Search an external workbook for the word "Salary"
    -IF "Salary" is not found I need to skip the part of my code that would reference where salary is found
    -IF "Salary" is found, continue on normally with the code

    If I need to explain more, I'd love to.

    Thanks.

  2. #2
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: VBA - If value not found, skip part of macro.

    Hi ideally you should split the macros up
    Please Login or Register  to view this content.
    or you can use the goto statement but this is throwned upon

    Please Login or Register  to view this content.
    Regards
    Sean

    Please add to my reputation if you think i helped
    (click on the star below the post)
    Mark threads as "Solved" if you have your answer
    (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code:
    [code] Your code here [code]
    Please supply a workbook containing example Data:
    It makes its easier to answer your problem & saves time!

  3. #3
    Registered User
    Join Date
    05-23-2013
    Location
    Iowa
    MS-Off Ver
    Excel 2007
    Posts
    84

    Re: VBA - If value not found, skip part of macro.

    Hi Sean,

    I'm sure I really follow you.

    I need the macro to search the workbook Census Tester for the value "Salary". If the macro doesn't find "Salary", it will skip the part of my macro that pulls salary data. If the macro does find "Salary", it goes on normally.

    Thanks.

  4. #4
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: VBA - If value not found, skip part of macro.

    Hi,
    thats what the above format does!
    It was just a demonstration to show that you can split your macro up into sections and then call each section depending on if Salary is found.
    Or you can leave as one macro but use the goto statement to jump to a certain part of your macro.

    If you were to upload a workbook with your macro in, or at least upload your macro i might be able to help more.

+ 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