+ Reply to Thread
Results 1 to 7 of 7

Skip part of code depending on cell value

  1. #1
    Registered User
    Join Date
    08-16-2016
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    88

    Skip part of code depending on cell value

    Hi

    I have some code where I'd like to skip a section depending on a cell value, in regular English this is what I mean....



    CODE
    CODE
    CODE
    CODE
    If Sheet1 Cell A5 = 5 then JUMP TO "HERE"
    CODE
    CODE
    CODE
    CODE
    HERE
    CODE
    CODE
    CODE
    CODE
    CODE


    So basically if cell A5 is 5, then miss the code between "HERE and "HERE". If A5 does not equal 5 then run all the code.

    Any ideas?
    Thanks :D

  2. #2
    Forum Contributor
    Join Date
    09-05-2011
    Location
    Essex, England
    MS-Off Ver
    Excel 2003 Excel 2007
    Posts
    383

    Re: Skip part of code depending on cell value

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-16-2016
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    88

    Re: Skip part of code depending on cell value

    Hi,

    Thanks :D
    How do I properly reference the cell and insert an If statement... something like?


    Sheets(Sheet1).Range.("A5") = 5

    And how do I define "here" as a something I can use?

    Thanks

  4. #4
    Forum Contributor
    Join Date
    09-05-2011
    Location
    Essex, England
    MS-Off Ver
    Excel 2003 Excel 2007
    Posts
    383

    Re: Skip part of code depending on cell value

    1. If Worksheet("Sheet1").Range("A5") = 5 then goto here.

    2. you can use almost any reference in the goto statement as long as you add a colon ( to the same reference further down your code. you do not need to declare it as you would a variable.

  5. #5
    Registered User
    Join Date
    08-16-2016
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    88

    Re: Skip part of code depending on cell value

    That's great, thanks!

  6. #6
    Registered User
    Join Date
    03-08-2020
    Location
    Stamford, CT
    MS-Off Ver
    2019
    Posts
    8

    Re: Skip part of code depending on cell value

    I am new to forums and let me know if I need to start a new Post.
    I have something very similar and need some help.

  7. #7
    Registered User
    Join Date
    03-08-2020
    Location
    Stamford, CT
    MS-Off Ver
    2019
    Posts
    8

    Re: Skip part of code depending on cell value

    Hi,
    I am new to forums and let me know if I need to start a new Post.
    I have something very similar and need some help.

+ 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. How to skip a line in a macro depending on a value
    By Serhattem in forum Excel General
    Replies: 2
    Last Post: 08-13-2016, 02:57 AM
  2. [SOLVED] Delete part of rows, depending if there is a value or not in a cell
    By excelactuary in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-08-2013, 08:28 AM
  3. [SOLVED] populating a cell depending on A PART OF another cell's value
    By 11x in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-21-2012, 12:33 AM
  4. VBA code if cell is null - skip
    By louisefleming in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-17-2011, 05:57 PM
  5. VBA Code Vlookup Skip Cell if no new information
    By learningexcelyup in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-11-2009, 02:28 PM
  6. How do I skip part of a macro?
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-26-2008, 06:39 PM
  7. function to count the amount of cells depending on part of the cell entry
    By Andyd74 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-25-2006, 06:20 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