+ Reply to Thread
Results 1 to 2 of 2

Code to skip a line

  1. #1
    Registered User
    Join Date
    07-25-2017
    Location
    London, UK
    MS-Off Ver
    Office 2016
    Posts
    8

    Code to skip a line

    This is my first foray into VBA macro - so forgive me if things are a bit messy.

    I have a list of excel documents, *most* of which are based on a template and the code below opens each excel file, pulls the required data from defined cells and drops into the summary document.

    When it comes across an excel file that is not using the template the code fails. I'm guessing as the sheet it is seeking is not present.

    I would like to add some logic so that if it opens a file which does not have the sheet name present it will close the file and skip to the next file (and perhaps insert "N/A" or similar to the summary destination cell.

    Anyone able to help?

    Many thanks...

    Please Login or Register  to view this content.
    Last edited by StKi1da; 08-09-2017 at 08:12 AM.

  2. #2
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Code to skip a line

    You could probably just get away with On Error Resume Next before your For x line, however this could mask other errors.

    But please can you update your post to ensure your code is between the code Tags

    [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code]
    Please do add reputation where you see fit, it's nice to be nice and we all enjoy a pat on the back

    Please also mark your thread as solved once it has been.

+ 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. [SOLVED] How to tell this 1 line of code to skip blanks
    By 80Wil in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 04-26-2017, 01:56 PM
  2. 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
  3. Replies: 4
    Last Post: 03-24-2016, 03:20 PM
  4. [SOLVED] False value, then skip to next line, etc.
    By hidden78731 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-24-2016, 03:10 PM
  5. How to skip line in Code
    By toci in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 03-06-2016, 01:39 AM
  6. Skip line if cell is empty
    By Krist2 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-03-2015, 09:56 AM
  7. Need Chart's Line to Skip Zero Values
    By ComcoDG in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 10-14-2008, 11:27 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