+ Reply to Thread
Results 1 to 4 of 4

Upon error, skip and continue

  1. #1
    Forum Contributor
    Join Date
    06-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2016
    Posts
    144

    Upon error, skip and continue

    Hello. I use a spreadsheet for renaming a load of files at once.

    My code goes through all cells from J5 to J500, this is the current file name. The new file name is in column K

    Please Login or Register  to view this content.
    The problem I'm having is when I encounter an error. For example I sometimes get Error 58: File already exists.
    How do I change my code so if I encounter an error, skip the renaming, and move onto the next cell and continue

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,861

    Re: Upon error, skip and continue

    On error resume next

    https://msdn.microsoft.com/en-us/library/5hsw66as.aspx
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    06-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2016
    Posts
    144

    Re: Upon error, skip and continue

    Ah thanks, if only all my vba problems were this easy to fix.

    Is there a way to determine what to do depending on what error message it is.
    For example, if error 58, put 1 at end of filename. If same error occurs again, put 2 at end of filename etc. etc.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,861

    Re: Upon error, skip and continue

    Have you tried adding and Elseif line to your code.

+ 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. Ignore error and continue
    By Hezcal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-05-2015, 10:05 AM
  2. [SOLVED] Skip "False" in IF and continue numbering in cell until True match, then move down cell
    By simonfinnerty in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-06-2015, 06:06 PM
  3. Caputre WB name on error and continue
    By Coleman34 in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 10-08-2014, 04:13 PM
  4. Continue to get Sub not defined error? Can anyone help?
    By cody4334 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-18-2012, 05:00 PM
  5. Replies: 0
    Last Post: 10-13-2011, 01:11 PM
  6. Code error, highlight error, continue to RUN
    By JohnSeito in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-07-2008, 01:29 AM
  7. Replies: 1
    Last Post: 03-21-2005, 12:03 PM

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