Results 1 to 12 of 12

VBA Worksheet select error.

Threaded View

  1. #1
    Registered User
    Join Date
    07-14-2009
    Location
    CT, USA
    MS-Off Ver
    Excel 2016
    Posts
    71

    VBA Worksheet select error.

    Hi, I attached my workbook so you guys can easily take a look.
    In this workbook I have 2 hidden worksheets.

    To start off, you click the Add Week button, put in a date (mm-dd-yy), that brings up the sheet thats named with the date you just put in the text box. (Which happens to be placed in the wrong spot) In that sheet that appears theres a button to "Delete last" which is suposed to delete the last sheet in the worksheet but the new sheet gets placed between the existing charts. Thats my first problem.

    Next, when you hit the delete button, my VBA code is set to make one of the hidden sheets visible so it can delete one of the rows.

    Sheets("Total WO Table").Visible = True
    Its fine deleteing the row, but when I go back and select this sheet again I get an error with the selection.

    Worksheets("Total WO Table").Select
    even though I have the exact same line of code just before and it doesnt give me an error.

    Heres a snipet of the code but you guys can take a look at the actual file for the full thing.

        Sheets("Total WO Table").Visible = True
        Worksheets("Total WO Table").Select
        Sheets("Total WO Table").Move Before:=Sheets(4)
        
        Worksheets(Worksheets.Count).Select
        nameD = ActiveSheet.name                 'Name of last sheet as variable
        
        ActiveWindow.SelectedSheets.Delete      'Deletes last sheet
        
        
        Worksheets("Total WO Table").Select   '<--- This is where error occurs.
    Attached Files Attached Files

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