+ Reply to Thread
Results 1 to 5 of 5

My VBA code stopped working please help.

  1. #1
    Registered User
    Join Date
    12-16-2016
    Location
    New Mexico
    MS-Off Ver
    2007
    Posts
    36

    My VBA code stopped working please help.

    I can't seem to spot the error in my code when I changed my Sheets(1) to Sheet1 in my code so that way I could have multiple sheets not included in the code. This code takes everything from Sheet1 and moves it to sheets i call ABQ 2015 & ABQ 2016 when it finds proper dates dates. I'm getting no errors but nothing is moving.

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: My VBA code stopped working please help.

    There's no essential difference between Sheets(1) and Sheet1 if Sheets(1) is the leftmost tab and it also has the VBA Sheet Code Name 'Sheet1'.

    Have you stepped through the code to see whether you ever enter the IF condition.

    Otherwise upload the workbook.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: My VBA code stopped working please help.

    There is a difference between Sheets(1) and Sheet1. Sheet(1) is the first worksheet tab, while Sheet1 is the name of a particular worksheet. Is it possible that your Sheet1 is not the 1st tabbed worksheet?

  4. #4
    Registered User
    Join Date
    12-16-2016
    Location
    New Mexico
    MS-Off Ver
    2007
    Posts
    36

    Re: My VBA code stopped working please help.

    It's not the first tabbed worksheet it is the last. Is that what my problem is?
    EDIT: Thanks Dangelor I had tabs in wrong order that was an easy fix.
    Last edited by Dark0Prince; 01-10-2017 at 03:58 PM.

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: My VBA code stopped working please help.

    Quote Originally Posted by dangelor View Post
    There is a difference between Sheets(1) and Sheet1. Sheet(1) is the first worksheet tab, while Sheet1 is the name of a particular worksheet. Is it possible that your Sheet1 is not the 1st tabbed worksheet?
    You missed the important bit where I said "if Sheets(1) is the leftmost sheet tab AND it also has the VB CODE name Sheet1"

    @DarkOPrince.

    There are three ways of directly referencing a particular sheet.
    1. Sheets(x) where x is an index number representing the number of sheets across the tab names starting with the left hand sheet. So Sheets(3) will be the third sheet from the left

    2. Sheets(string) where string is the sheet tab name.

    3. Sheetx where x is any integer. This is the VBA sheet code name.

    You should always work with the VBA code name since the sheet tab name is too easily changed which will cause any code that uses it to fall over. Similarly avoid the sheet index number since a sheet tab can be dragged to another position on the bar that contains the sheet tab names.

  6. #6
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: My VBA code stopped working please help.

    Glad I could help! More importantly, Richard's advice is well worth heeding...
    You should always work with the VBA code name since the sheet tab name is too easily changed which will cause any code that uses it to fall over. Similarly avoid the sheet index number since a sheet tab can be dragged to another position on the bar that contains the sheet tab names.

+ 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] VBA Code is stopped working?
    By stoicy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-29-2016, 05:26 PM
  2. My worksheet code stopped working
    By SiddiqFarid in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-24-2015, 07:23 AM
  3. [SOLVED] Save code stopped working
    By Sc0tt1e in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-02-2014, 07:18 AM
  4. [SOLVED] Why has my code stopped working?!
    By JamesFletcher in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-21-2013, 07:07 AM
  5. Excel code stopped working
    By Jollyfrog in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-28-2010, 07:34 AM
  6. Code stopped working
    By kinleyr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-16-2010, 12:25 PM
  7. Code stopped working
    By chris46521 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-09-2006, 10:05 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