Hello,
I have an Excel workbook that has a number of sheets, where "Graphs" begin at Sheet16 and can either be a couple sheets, or many (i.e. 20).
Could someone assist on how I can code to select sheet16 through the end of the workbook, and then simply delete the sheets?
So far I've tried the following with no success (it eliminates some sheets, not all). Thanks in advance for your help!!!
----------------------------------------------
Dim iSheetCount As Integer
Dim iSheet As Integer
Dim ws As Integer
Application.DisplayAlerts = False
On Error Resume Next
iSheetCount = ActiveWorkbook.Worksheets.count
For iSheet = 16 To iSheetCount
Worksheets(iSheet).Delete
Next iSheet
Application.DisplayAlerts = True
5 1628
may be changing the for loop works
Try this
For iSheet = iSheetCount To 16 Step -1
Worksheets(iSheet).Delete
Next iSheet
Hello,
I have an Excel workbook that has a number of sheets, where "Graphs" begin at Sheet16 and can either be a couple sheets, or many (i.e. 20).
Could someone assist on how I can code to select sheet16 through the end of the workbook, and then simply delete the sheets?
So far I've tried the following with no success (it eliminates some sheets, not all). Thanks in advance for your help!!!
----------------------------------------------
Dim iSheetCount As Integer
Dim iSheet As Integer
Dim ws As Integer
Application.DisplayAlerts = False
On Error Resume Next
iSheetCount = ActiveWorkbook.Worksheets.count
For iSheet = 16 To iSheetCount
Worksheets(iSheet).Delete
Next iSheet
Application.DisplayAlerts = True
Hi
I think more info is require.
Do we assume that all sheets to be deleted have 'Graphs' (Charts) in them??
You do not say which sheets are not deleted, that should be, or give any clue as to why not (are they perhaps charts and not sheets?).
MTB
Hello,
Thanks for the feedback.
I've made the Excel tool so the additional sheets will always be starting at "Sheet16", and then go towards the end of the workbook.
The names of the sheets are always changing, therefore I'd prefer to have the code to delete "Sheet16" through the end of the workbook, whether it be "Sheet20", or "Sheet57".
Not all of the Sheets have graphs.... some only data.... I simply want to delete those sheets with a macro.... with the press of a button.
Thanks again for your help!
Hello,
Thanks for the feedback.
I've made the Excel tool so the additional sheets will always be starting at "Sheet16", and then go towards the end of the workbook.
The names of the sheets are always changing, therefore I'd prefer to have the code to delete "Sheet16" through the end of the workbook, whether it be "Sheet20", or "Sheet57".
Not all of the Sheets have graphs.... some only data.... I simply want to delete those sheets with a macro.... with the press of a button.
Thanks again for your help!
Just to confirm, you want to delete all SHEETS after sheet 15 that have an EMBEDDED chart and leave all sheets that contain data only ??
If this is the case, and you do not know what the sheet name(s) are, then this becomes tricky because you cannot define "Sheet15" or later.
MTB
Actually it won't matter what's in the sheets... chart, no chart, just data, embedded picture... I just want anything greater than sheet #15 deleted.
I'd also like to know how to delete named sheets from sheet named "Total" to a sheet named "Data", and everything in between. This may sound odd, but we get data from an outside vendor that can have many sheets, but their first sheet is always named "Total", and last sheet is named "Data". I want to delete both the "Total" & "Data" sheets, and every and any sheets in between.
Thanks again for asking questions to clarify what I'm looking for!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ilan |
last post by:
Hi all
I need to add data from two Excel sheets (both on the same workbook)
to an existing table in my SQL DB.
The problem is that each sheet holds different fields for the same
record, though...
|
by: sunilkeswani |
last post by:
I need help with exporting data from 2 access tables, into 2 existing
spreadsheets in a single Excel file.
Currently, I am using this code:
DoCmd.TransferSpreadsheet acExport, 8, "Table1",...
|
by: Esmail Bonakarian |
last post by:
Greetings all,
What is the best way to access specific records in an Excel file?
I have an Excel file, I want to randomly and repeatedly (maybe around up to
50 times) draw some rows of data...
|
by: madeleine.macphail |
last post by:
All
I'm currently attempting to move us from a spreadsheet based system to
a database system. The first phase is to import the data on a regular
basis from the spreadsheets to get the database...
|
by: mwilliams4 |
last post by:
I have an Access 2003 table that I want to generate into tabbed Excel
2003 workbooks using a button on a form.
The tables would need to overwrite everytime that the button would be
pressed.
...
|
by: Harshe |
last post by:
hello all,
I am trying to code, but i am just stuck after importing one sheet. so here is the gist of what i need help with.
In a workbook at the start of the year (january) i will have 4...
|
by: afromanam |
last post by:
Regards,
Please help
What I'm trying to do is this: (and I can't use reports since I must export to Excel)
I export some queries to different tabs in an excel workbook
I then loop through...
|
by: deve8ore |
last post by:
Hello,
I have an Excel workbook with ~ 21 sheets in it.
Let's say 7 are named "Red1", "Red2", "Red3", ect....
Another 7 are named for "Green1, 2, 3", ect...
and the last 7 are named "Blue1, 2,...
|
by: grippy10 |
last post by:
I'm trying to delete sheets 1,2,4,5 and make sheet 3 the active one. I get the error on " Sheets(1).Select" and "Sheets(Array(1, 2, 4, 5)).Select". I get a run time error when I try and run the...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |