I have a list of worksheets and want to delete the last X worksheets as listed in column B in worksheet(1). Also, I get an error the first time I run this code but not the second time.
Please Login or Register to view this content.
I have a list of worksheets and want to delete the last X worksheets as listed in column B in worksheet(1). Also, I get an error the first time I run this code but not the second time.
Please Login or Register to view this content.
What's the error message you get and how many sheets in total do you have?
There is nothing in the delete loop that takes account of any names listed on the left hand sheet tab. And although the ClearContents instruction is commented out it doesn't make sense.
Columns ("A") or Columns(1) would.
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.
You need to delete from right to left with that indexing. Think about it.Please Login or Register to view this content.
Either that, or
Please Login or Register to view this content.
Entia non sunt multiplicanda sine necessitate
I get a "Run-time error'9': Subscript out of range" and it stops at line "Sheets(N + i).Delete"
The number of sheets in total and to delete will vary. I currently have another macro that will list out all the sheets in column A. From there I'd like to skip the first N sheet names and delete any sheets after that along with the list of sheet names in column A.
Ok, here is the last line I need to figure out why it isn't working. Any assistance is appreciated.
Please Login or Register to view this content.
Last edited by sdgenxr; 12-03-2015 at 04:13 PM.
What happens?
What are the worsheet names, exactly?
It deletes some of the worksheets then errors out with a runtime error. The worksheets are named "FY14" etc.
Worksheets and other collections renumber as items are deleted, so you need to loop backwards:
Please Login or Register to view this content.
I see. Thank you for the assistance!
Maybe:
Please Login or Register to view this content.
Better .
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks