Macro for sheet delete, very easy

my code is:
Sheets("Sheet 1 (2)").Select
ActiveWindow.SelectedSheets.Delete

How can i hace it delete the seleted sheet, not always 'Sheet 1 (2)'?


-- 
comotoman
------------------------------------------------------------------------
comotoman's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=27292
View this thread: http://www.excelforum.com/showthread.php?threadid=475211

0
10/11/2005 9:43:15 PM
excel.misc 78881 articles. 5 followers. Follow

1 Replies
495 Views

Similar Articles

[PageSpeed] 38

This code deletes the active sheet, with no prompt for confirmation:

Application.DisplayAlerts = False
ActiveWindow.SelectedSheets.Delete

0
CycleZen (674)
10/11/2005 10:19:53 PM
Reply:

Similar Artilces:

The Item could not be deleted. It was either moved or already deleted, or access was denied.
This is a multi-part message in MIME format. ------=_NextPart_000_0008_01C42C5B.11C3D7B0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I had to rebuild a corrupt database this morning. My Priv.edb and = Pub.edb were the files I worked on with the ESEUTIL. Everything is = working except users are complaining that they cannot delete e-mails = that were "zapped" during the rebuild process. The message they're = receiving is " The Item could not be deleted. It was either moved or = already deleted, or access was denied...

Delete rows with true or false
Hi, I want to delete all the rows that contain the word true or false. How can I do this? Thanks Diana wrote: > Hi, > > I want to delete all the rows that contain the word true or false. How > can I do this? Can you sort on the column containing true or false, then select all the rows in one group and delete them? Or does it need to be automatic? -- Jordon If the data is in one column, you could apply data|filter|autofilter (in xl2003 menus) to that column. Show the rows that contain either True or False and delete the visible rows. Then remove the au...

disable unhide sheets on toolbar
Hello is there a way to dis-able the unhide sheets toolbar? TIA, Ditchy Hi Ditchy Protect the workbook (Tools > Protection menu) to prevent hiding, unhiding and renaming of sheets. HTH. Best wishes Harald "ditchy" <ditchy@ncable.net.au> skrev i melding news:1115110468.548181.247220@g14g2000cwa.googlegroups.com... > Hello > is there a way to dis-able the unhide sheets toolbar? > TIA, Ditchy > If you want to take out that control then use Application.CommandBars("Worksheet Menu Bar").Controls("Format").Controls("Sheet").Co...

spell check does not visually cycle through cells when run from macro?
I'm trying to recreate the same behavior in a macro that spellcheck has when the spellcheck button is pressed. The spellcheck does not cycle through the cells visually when run from a macro, so when there is a misspelled word, you cannot see the cell it is a part of. If anyone knows how I can get this behavior to work, it would be GREATLY appreciated. I did a record new macro, and got code similar to the following: Sub testSpelling() Range("F2:F500").Select Selection.CheckSpelling SpellLang:=1033 End Sub thanks, dan Dan, Add the fiollowing to your code as shown: ...

Setting directory for file save in macro
Hi Thanks to a generous poster I now have a great bit of code to use in a macro for Excel which saves a text file (I'm no VBA programmer so this was really helpful), i.e.: Open "Test.txt" For Output As #1 (rest of code) My problem now is this: The macro saves test.txt to Excel's current active folder, rather than the folder that the current workbook is contained in. For example, if I last saved an Excel workbook to c:\workbooks\, and the workbook that I have open exists in c:\workbooks\workbook1\, when I run the macro it saves the text file in c:\workbooks\. If I ...

How to record percentage increases in materials costing sheet.
I am trying to do a materials costing sheet where I would like to be able to periodically increast the base cost of the product by different percentages. E.g. Cost of Apples $10.00 but might be increased by 5% then 2.5% and therefore the base cost would keep changing. I know how do first % increase but not how to then use that figure as the base figure for future adjustments. Thanks for amy help. I am very new to this. You could put a % in one cell. Select the cell and give it a name by Insert-->Name-->Define. Call it "increase". Then, in the cell where you put the f...

Range of an Excel Sheet
I want to open a linked Excel Sheet with the appropriate range. The excel filename / range I have is the following: C:\Documents and Settings\aparmar\Desktop\Book1.xslx!Sheet!R1C1:R5C2 I'm opening the following by stripping of the extra information : C:\Documents and Settings\aparmar\Desktop\Book1.xslx How do I select the Range in Excel using !Sheet!R1C1:R5C2 ? thanks, Amrit Command lines to open workbooks do not include specific sheets and ranges. To open to a specific sheet and range selection you must use VBA Name the range then add this code to Thisworkbook module of Book1...

Can you record a macro in Publisher like you can in Excel?
In Excel I use the feature to Record a Macro. Excel records the keystrokes and converts to VB. Does Publisher have that option? In my version, Publisher 2003, I can Create a Macro, and it takes me into VB. However, I don't know how to code VB. Darlene wrote: > In Excel I use the feature to Record a Macro. Excel records the keystrokes > and converts to VB. Does Publisher have that option? In my version, > Publisher 2003, I can Create a Macro, and it takes me into VB. However, I > don't know how to code VB. Publisher does not have a Macro Recorder, sorry. --...

Macros/Signatures Question
I have an Excel Workbook that I created for a PC Order Form. I set it up to only make certain rows visible based on the Machine Model that they choose. I digital signed the Worksheets and exported the Digital Signature Certificate and installed it on the User’s PCs. The code works great. The user opens the Workbook and it runs the Macros with no problem. The problem I have is when the user goes to save the Workbook. They get an error that “Excel can not sign VBA macros when saving to this file format. Do you want to remove the digital signature and continue saving this workbook?”...

Macro Copy and Paste
I am currently trying to copy from one workbook that has 7 differen tabs and paste into one worksheet on a separate master workbook. M problem is that when I set up the macro to copy from one of the tabs i the workbook and paste to the other work book, I only want the the row to come in where there is data. Currently I am having to run a macr that takes every 100 lines, but ideally I only want the informatio copy and pasted where there is only data. In addition, once I have copy and pasted everything from the first tab my next step is to copy and paste information from the second tab t th...

Referring to a FileName in Macro
I have a Macro with the following code Application.Run "TestQry!Macro2" Application.Run "TestQry!Macro1" TestQry is the name of the file. Is there anyway that this macro cod can refer to the activeWorkbook or filename so that if the file i saved to a new name this macro will still ru -- Message posted from http://www.ExcelForum.com How about just: macro2 or even call macro2 "DoctorV <" wrote: > > I have a Macro with the following code > > Application.Run "TestQry!Macro2" > Application.Run "TestQry!Macro1" > &g...

Macro Question #10
Hi, I am working with a text file that I imported into Excel. It is a transactional report of sales by customer. The data will have the customer number and name spread out over three cells. What I want to do is to create a macro that will contatenate all three cell and then perform a paste special and paste them into another cell in another column. Since the number of transactions by customer can vary the customer name and number can appear anywhere on the page. I created a macro to do this using the first customer which appears in cell B5 through D5. The next customer appears...

Unable to delete the Dead Domain controller
Dear, Iam working on windows server 2008 Ent Ed I have two doman controllers in the domain both are GC but only one domain controller has all the fsmo roles but iam having replicattion problems with the dead DC (i.e mppkw-database) and Iam unable to delete or remove the dead domain controller from the domain and iam having follwing problems using the ntdsutil :- matadata cleanup select operation target: list domains Found 1 domain(s) 0 - DC=mediaphoneplus,DC=com select operation target: select domain 0 No current site Domain - DC=mediaphoneplus,DC=com No current server N...

Sheet outline range.
How can I determine in vba the range occupied by a sheet? The edges of the sheet may be "ragged" ie. there will be blank cells within the range and at its edges - I want to determine the overall rectangular occupied outline to use in a Range statement. TIA Chris Depending on what you want, you may want to try .usedrange. msgbox worksheets("Sheet1").usedrange.addresss (for example) Be aware that excel keeps track of the usedrange in a way you probably don't--it remembers the last used cell, even if you've cleared that cell. Debra Dalgleish...

Spreadsheet macro stopped working!
Hi, I recently made an Excel spreadsheet for keeping track of my golf score. The spreadsheet is quite simple. It consists of 4 sheets: Scorecard, statistics, database and equations (for calculating some specific). I insert informations about the golf course I'm playing and how my score was etc. I then hit a button "Save scorecard" that runs a macro. The macro inserts specifik values from the scorecard into the database sheet (which works like a charm). The macro also updates the "Statistics" sheet with information about stroke number and points for ...

Excel 2007 macro compatability
I have created a macro in Excel 2007 that includes importing a text file. It works fine on my PC, but fails on a co-workers PC running Excel 2000. The failure points to the "TextFile Platform" command in the macro. I have tried several (437, 1252, 20127), but get the same results. Any solution? Thanks you. Have you try xlWindows -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "Al @ Frontier" <Al @ Frontier@discussions.microsoft.com> wrote in message news:3F601F80-F099-42C8-AA18-6D31A85946F9@microsoft.com... >I have cr...

Excel E-mail Macros
I need to know how to create a macro that will send an excel file as an attachment to one individual, and then send one of the file's worksheets to 3 e-mail addresses using the mail recipient method so that the worksheet appears in the body of the e-mail. The e-mail program I am using is Outlook. Any help with this will be GREATLY appreciatd. Hi John, I'd tell you, but Ron de Bruin already did all the work. It'd be silly for me to do it again...Try Ron's site: http://www.rondebruin.nl/sendmail.htm tim "John" <jbegley@dcas.nyc.gov> wrote in message ne...

format macro
Last week, Art was trying to help me with this, but the solution doesn't work for me. I'm looking for a macro that would be contained within my personal.xls, that I could use as needed. Lets say I have A1:C5 selected, which represent headdings and data for jan, feb and march. [On a different spreadsheet, it may be different columns, or a different number of columns. The point is that I will select the range before I run the macro.] I want to do an auto fit for each column, so that the column widths are big enough to fit the numbers. No problem, format-->column-->autof...

reduce poster to regular sheet
Win 2002/XP Is there a function in Publisher to take a 11 & 17 poster -"shrink" and print out on 8-1/2 X 11 paper ? Thank you Pat Joram pjoram@monroecc.edu What version Publisher??? Some printers have Zoom Smart... Look at your printer options. You can select all, copy, paste special, picture and shrink it that way. -- Mary Sauer MS MVP http://office.microsoft.com/ http://www.msauer.mvps.org/ news://msnews.microsoft.com "Pat" <pjoram@monroecc.edu> wrote in message news:OMlCDHQvEHA.536@TK2MSFTNGP11.phx.gbl... > Win 2002/XP > > Is there a function...

Sort a 'Protected' sheet
Using Excel 2002, when I try to sort a protected sheet with a macro, I get a dialog box with 'Run time error 1004'. I allowed sorting when I set up the macro. Do I need to 'unprotect' the sheet with the macro and then 'protect' it again after the macro does its sorting? Any suggestions? Thanks, Barney As ALWAYS, post your coding efforts for comments -- Don Guillett Excel MVP SalesAid Software dguillett1@austin.rr.com "Barney" <barneypo@no-spambellsouth.net> wrote in message news:srMii.817$yD2.605@bignews1.bellsouth.net... > Using Excel ...

Invisible Excel sheet
Hi Very strange one for you. I have an Excel 2000 sheet. I can open it fine. I pass the same sheet via email and floppy disc to a colleague. When he opens the file, the file apparently opens, but it is totally invisible. When you try to reopen the file (without having closed down the file, because it looks like nothing has been opened, it says that the file is already open. You can navigate around this invisible file (you can see the cell reference change as you move the arrow buttons. We have: Checked that the sheet is not hidden Checked that the window is not hidden. Re-installed Office. ...

Remake deleted account in Windows Live Mail
Hi, is it possible to remae an acount I have removed from Windows Live Mail ? Or just a possibility to import the emails there was in the 2 account I removed ? I did not think the program would delete the emails, when I removed the account settings. Hope someone can help, as there are some emails I would like to save. Best wishes Steen Did you look on the web access for those accounts to see if the emails are still out there? "steendk" <steendk@discussions.microsoft.com> wrote in message news:652B3826-1F5C-4309-99DC-7EE579109C44@microsoft.com......

How do I keep a formula from changing if a row is added or deleted
I have a formulas referencing cells in another worksheet. When rows are added or deleted from the worksheet the formulas are either changed to skip the new row or receive an #REF! error when a row is deleted. Regardless of what happens in the worksheet I want the formulas to remain the same. Hi see your other post -- Regards Frank Kabel Frankfurt, Germany cwolt wrote: > I have a formulas referencing cells in another worksheet. When rows > are added or deleted from the worksheet the formulas are either > changed to skip the new row or receive an #REF! error when a row is >...

macro problems!
i have a check box whose control source is: =[Total In Stock]-[reorderlevel]<=0 how can i set the control to only be visible if this check box is true? tried macro and vba, but can't quite work it out. thanks in advance Paul ...

Macro #17
Does anyone have a Macro to edit a cell to add "=" sign at the beginning of the data Thanks, Alexandra can you be more pacific ActiveCell.FormulaR1C1 = "=" Range(" ").Select Alexandra wrote: > > Does anyone have a Macro to edit a cell to add "=" sign at the beginning of the data? > > Thanks, Alexandra ...