+ Reply to Thread
Results 1 to 8 of 8

Delete worksheets based on criteria

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Delete worksheets based on criteria

    I think you just need to nest the conditions together and use the rows count instead of a cell value.

    
    'Delete worksheets that have fewer than 200 records
            For I = 1 To ActiveWorkbook.Worksheets.Count
                    If Not Sheets(I) = Sheets("vqueue") Or Sheets(I) = Sheets("Sheet1") Then
                          If Sheets(I).Range("B2:B" & lastRow).Rows.Count < 200 Then 
                               Sheets(I).Delete
                          End If
                    End If
            Next I
    Last edited by cubangt; 07-06-2021 at 05:53 PM.
    If you find the suggestion or solution helpful, please consider adding reputation to the post.

  2. #2
    Registered User
    Join Date
    06-28-2021
    Location
    Colorado, United States
    MS-Off Ver
    Office 365
    Posts
    5

    Re: Delete worksheets based on criteria

    When I run the code, I get a run-time error 438 - object doesn't support this property or method on the following line:
    If Not Sheets(I) = Sheets("vqueue") Or Sheets(I) = Sheets("Sheet1") Then
    I'm not quite sure how to fix the error.

+ 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. Compare 2 Worksheets based on single criteria and then delete row
    By jejnycta in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 01-17-2019, 05:12 PM
  2. [SOLVED] Split to Workbooks based on a Column followed by Worksheets based on another criteria
    By jaredli in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-26-2018, 03:27 AM
  3. [SOLVED] delete worksheets based on color
    By xi603 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-13-2017, 02:14 PM
  4. Delete rows based on the same value in different ranges of different worksheets
    By JamesTheRock in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-08-2016, 05:38 AM
  5. Delete worksheets based on a list
    By khan_solo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-13-2015, 07:05 PM
  6. [SOLVED] Delete Worksheets Based on Name from InputBox Criteria
    By d247 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-10-2014, 01:45 AM
  7. Delete Worksheets Based On Name
    By Fermented Reptile in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-18-2012, 11:02 AM

Tags for this Thread

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