I have a workbook that has address information in it. One worksheet contains all data for all states, another worksheet contains summary data, and the other worksheets are for each individual state with the data copies from the worksheet that has all the data in it. I would like to delete any worksheet that does not have more than 200 records. I did try just adding worksheets that have more than 200 records rather than creating a delete subroutine, but I got farther with the delete. I do not want the worksheets containing all data ("vqueue") or the worksheet containing summary information ("Sheet1") to be deleted. I keep getting errors when I run the following code. Can anybody provide insight Thank you in advance!
Note that AF2 contains the number 200 as I could not seem to get it to work otherwise.![]()
'Delete worksheets that have fewer than 200 records For I = 1 To ActiveWorkbook.Worksheets.Count If Sheets(I) = Sheets("vqueue") Or Sheets(I) = Sheets("Sheet1") Then Else If Sheets(I).Range("B2:B" & lastRow).Value < Sheets("vqueue").Range("AF2").Value Then Sheets(I).Delete End If Next I
Bookmarks