Delete A Worksheet Using A Macro

Feb 22, 2010

I have recorded a macro to copy a worksheet, perform some operations on the copy then delete the copied worksheet. My problem is that when running the macro I get a dialog box asking me if I am sure that I want to delete the sheet and I need to press OK. How can I get the macro to say it is OK to delete the sheet?

The last line of my macro is ActiveWindow.SelectedSheets.Delete. I have tried things like:- ActiveWindow.SelectedSheets.Delete = TRUE

View 2 Replies


Macro - Delete Row From Worksheet 1 And Add To Worksheet 2

Jun 28, 2007

I am maintaining an issues list in excel. File contains two worksheets/tabs: 1) Open Issues & 2)Closed Issues

One of the columns is Status. When an issues is in 'Complete' status, it is removed from Open Issues and added onto the 'Closed Issues' worksheet.

There are many issues closed daily and its quite a manual task to individually delete rows in one sheet and paste them at the end of the last row in the other sheet. Want to have a button/macro that would find any rows that have the cell for the status column w/ value 'Complete', delete it from 'Open Issues' sheet, and append it to the 'Closed Issues' shseet.

ive done basic c++ programing years ago, but know nothing about vba or excel macros.

View 13 Replies View Related

Macro To Delete Any Blank Rows In A Worksheet

Mar 8, 2009

I've added a button with a macro to delete any blank rows in a worksheet.

Cell A3 is completely blank and A6 has an IF formula which returns "". In my macro it copies the whole worksheet and then paste special values, to take away the formula in A6 and then deletes the blank rows but it still does not delete row 6.

View 4 Replies View Related

Excel 2010 :: Macro To Delete Last Line Of Data In Each Worksheet In Workbook?

Apr 24, 2014

I'm trying to create a macro that will look at each worksheet in a workbook and then delete the last line of data on each worksheet. The last row can vary on each worksheet. This is what I have come up with but it is not working. I am on Excel 2010 and Windows 7.

Sub Macro1()
Macro1 Macro
Dim ws As Worksheet


View 2 Replies View Related

Macro To Delete Numbers In Spreadsheet In One Column That Appear In Another Column Or Worksheet

Jan 20, 2013

How would you set up a macro to delete numbers in a spreadsheet in one column that appear in another column or worksheet?

In other words, if I have the numbers 1,2,3,4,5,6,7,8,9, 10 in one column and in the same column, or another column or worksheet I have the numbers 1,2,3,4,5 - I need a way to delete 1,2,3,4,5. I know how to delete duplicates via the advanced filter but I want to have the duplicate and original deleted.

View 3 Replies View Related

Macro Delete Page (delete A Sheet In A Macro But When I Run The Macro)

Jun 19, 2009

I want to delete a sheet in a macro but when I run the macro, I always get a message warning and I have to answer the msg box to delete the page. Below is the macro command I am using.


View 4 Replies View Related

Delete The Worksheet

May 11, 2004

I have a workbook with 3 worksheets. I am trying to delete 2 of the three but "Delete Sheet" is grayed out in both the "Edit" menu and RtMouseClick menu. The sheets are not protected and the workbook is shared. Do I have to un-share the workbook in order to delete sheete? If so.

View 9 Replies View Related

Delete The Line On Worksheet?

Jan 23, 2009

Need to delete the line on this worksheet and post how they did it.

View 2 Replies View Related

Can't Delete Buttons On Top Of Worksheet

Nov 26, 2013

I'm trying to delete the buttons on the top of this worksheet, and for some reason am not able to do so.

View 3 Replies View Related

Can't Delete Pages From Worksheet

Mar 3, 2014

I was trying to print a workbook which was about perhaps 20-30 sheets of roughly one page of printed info each. However, I saw the print job and it said it was printing over 7,000 pages!!!

It turns out there were about 4-5 worksheets which were blank (and also didn't have gridlines even though gridlines were checked on in options).

When I switched the sheets to page break view, lo and behold each sheet contained a few thousands "pages". I simply can't seem to reduce it down to a relatively normal size.

I tried going right past the edges of page 1 and deleting all columns/rows to the right and bottom of it to no avail. I selected the whole worksheet and removed all borders and any cell content with no luck.

I saw other "solutions" on the internet about copy/pasting the other unaffected sheets to a new workbook and deleting, but this seems cumbersome.

View 1 Replies View Related

How To Delete All Charts In Worksheet

Apr 7, 2014

I am tring to make a macro that will find all charts in a worksheet and delete them.

the macro is essentilally a monthly refresh that cleans out a template of charts that were pput in the previous month. As the chart names and the number of charts might vary from month to month I just want simple code to select all charts in the worksheet and delete them.

View 4 Replies View Related

Delete All Pictures In A Worksheet

Jan 21, 2009

I am absolutely new to visual basic thing but have a good idea of what I am doing in excel. I have seen some code to delete pics but can't figure out what it is that I am suppose to do. What I am doing is coping and pasting something from the internet. I do not need any of the pics that are pasted into the worksheet and am tired of deleting them individualy.

View 5 Replies View Related

Prevent Delete Worksheet

Aug 7, 2009

An old post provided the following macros that purportedly prevent users from deleting a worksheet. Unfortunately, it also makes it so you can't delete ANY worksheet in ANY file, which is of course not what was intended. Need figure a way to remove this nuisance? All attempts to delete a sheet keep looking back to the offending workbook, even though the macro has since been deleted from it.

Try pasting the following two event procedures into the Help sheet module:

Private Sub Worksheet_Activate()
Dim CB As CommandBar
Dim Ctrl As CommandBarControl
For Each CB In Application.CommandBars
Set Ctrl = CB.FindControl(ID:=847, recursive:=True)
If Not Ctrl Is Nothing Then
Ctrl.OnAction = "RefuseToDelete"
Ctrl.State = msoButtonUp
End If
End Sub................

View 4 Replies View Related

Delete Worksheet Code With VBA

Jan 19, 2010

Can someone help me out with this script?.

I keep getting "Subscript Out of Range Error"

I'm trying to delete all the code on sheets(1) of the active workbook.

View 8 Replies View Related

Delete All Macros From Worksheet

Nov 3, 2011

It's simple enough to delete all macros. I have a form that starts as a landing area for a bunch of data then it gets renamed. I want to delete both of my command buttons from the sheet and remove all of my macros. How am I going to pull this off, how can i save it to the sheet the first time?

Private Sub Workbook_BeforeClose(Cancel As Boolean)
'cut command buttons

[Code] .........

View 1 Replies View Related

Delete Worksheet With VBA From Different Workbook?

Dec 9, 2011

I am running VBA that will open a new workbook, at the end of that VBA code I have a line of code that reads:


When the code hits those lines it throws a VBA error 400. What do I need to do to have Sheet1 deleted from the "new" workbook?

View 2 Replies View Related

Delete Customers From Worksheet

Oct 22, 2008

I have exported a report out of Quickbooks with all my customers that have done business with us from 2005-2008. I want to be able to delete the customers from the worksheet that have done any business in 2008. So that I am left with a list of customers that have not done any business with us in 2008. Can a formula or macro do this for me. I don't just want to delete the rows that contain any dates in 2008, but delete the customer as a whole from the workbook.

TypeDateNumMemoNameItem@Home RealtyInvoice10/20/200522813BIC Clic Stic Black Barrel Red Trim White and Red Imprint Black Ink Medium Point@Home RealtyCSInvoice10/20/200522813Printing an additional color on the merchandise@Home RealtyADDCOLORInvoice10/20/200522813Shipping & Handling@Home RealtyShippingInvoice12/01/2005FC 2058Finance Charges on Overdue Balance@Home RealtyFin ChgInvoice07/18/200730753Silkscreen add web address to shirts@Home RealtySilkscreenInvoice07/18/200730753Silkscreening Set-up fee@Home RealtySet-upTotal @Home Realty1 Source ManufacturingInvoice08/16/2007311575-11/16"x7/16", Reversible, Standard Blade, Phillips Blade, Magnet Top, Nickel Plated, Heat Trea...1 Source Manufacturing8809Invoice08/16/200731157Set-up for Printing Plate1 Source ManufacturingPlate ChargeInvoice08/16/200731157UPS Ground Shipping & Handling1 Source ManufacturingShippingInvoice10/25/2007318755-11/16"x7/16", Reversible, Standard Blade, Phillips Blade, Magnet Top, Nickel Plated, Heat Trea...1 Source Manufacturing8809Invoice10/25/2007318755-11/16"x7/16", Reversible, Standard Blade, Phillips Blade, Magnet Top, Nickel Plated, Heat Trea...1 Source Manufacturing8809Invoice10/25/200731875Set-up for Printing Plate1 Source ManufacturingPlate ChargeInvoice10/25/200731875Shipping & Handling1 Source ManufacturingShippingInvoice07/08/2008343575-11/16"x7/16", Reversible, Standard Blade, Phillips Blade, Magnet Top, Nickel Plated, Heat Trea...1 Source Manufacturing8809Invoice07/08/200834357Shipping & Handling1 Source ManufacturingShippingTotal 1 Source Manufacturing

View 9 Replies View Related

Delete, Add, Move Worksheet

Apr 22, 2006

I've included bits of my code and some debug output. Whenever I attempt to add a worksheet, either BEFORE or AFTER I get the following ERROR MESSAGE: Method 'Add' of object 'Sheets' Failed. if I use the .add without before and after a worksheet is added. The problem is that it is always added before the active sheet. I need to replace a single sheet in the correct position of possible 10 sheets. I know the names of the sheets and which one I want to replace, but I can't get EXCEL to move sheets, add sheets by position Number or name, without getting the ERROR.

Public xlApp As Excel.Application
Public xlBook As Excel.Workbook
Public xlSheet As Excel.Worksheet
Public xlRange As Excel.Range
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
xlBook.Worksheets.Add After:="Accounts Receivable" *****
Accounts Receivable
Accounts Receivable

View 2 Replies View Related

Delete Worksheet If It Exists

Mar 1, 2007

Does anyone have SIMPLE code for this that can be run in a normal Sub. My worksheet will always be named "Cleaned". I have seen some posts regarding Functions and other things that seem more complicated than necessary.

View 9 Replies View Related

Delete All Shapes On Worksheet

Sep 26, 2007

I've written a macro that plots a graph directly in a white painted sheet, using lines and arrows figures.
The problem is that everytime I plot something, the xls-file gets larger, and the size doesn't change if I delete the figures. Since there's a lot of lines and arrows in my plot, I use 'Select All' and Edit-> Remove and this removes all figures, or at least for the eye. I suspect they are still left there somewhere, since the size grows with every new plot and since that sheet seems to have gotten a bit slower, when moving between cells.

Am I correct, or is there another reason for the size/ speed issue? If I my theory is correct, how do you permanently delete these "invisible" figures?

View 8 Replies View Related

Delete All ComboBoxes On Worksheet

Apr 22, 2008

On my Worksheet, I have a Commandbotton that executes this macro to delete all comboboxes in another sheet.

Sub DeleteShapes()
Dim obj As OLEObject
For Each obj In Sheets("Sheet").OLEObjects
If TypeOf obj.Object Is MSForms. ComboBox Then
End If
End Sub

This method works most of the time, but sometimes I get this error:
delete method of OLEObject class failed. I red in this forum, that I should set the TakeFocusOnClick Property of the CommandButton to false.

View 3 Replies View Related

Worksheet_change: Macro In One Worksheet To Run When Any Cell (in A Given Range)on A Different Worksheet (dataentry) Is Updated

Mar 27, 2007

I want a macro in one worksheet to run when any cell (in a given range)on a different worksheet (dataentry) is updated. I have spent along time trying to make it work with no avail. The code I use to start my macro is as follows.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count <> 1 Then Exit Sub

If Target(1, 1).Address = "dataentry!H5:IV72" Then
If Not Intersect(Target(1, 1), Range("dataentry!H5:IV72")) Is Nothing Then

On Error Resume Next
Application.EnableEvents = False

View 7 Replies View Related

Delete Forms CommandButton On Worksheet

Jun 5, 2006

How do I delete a command button I've entered on my Worksheetright-clicking does nothing;control-key+right-click does nothing alt+ctl+right-clicking does nothingWhat's the secret?

View 8 Replies View Related

Delete Cell When Worksheet Deleted

Jul 11, 2014

I want to delete a cell row in a table when I delete a corresponding worksheet with the same name as the cell.

For example, on the attached, if I delete the worksheet "Shawn" then I want row with "Shawn" deleted from the table on the "Example" tab. If I delete "Becky" worksheet then the row with "Becky" should be deleted from the table on the "Example" tab.

Delete cell when worksheet deleted.xlsx‎

View 4 Replies View Related

Subroutine To Delete A Row In Another Worksheet Not Work?

Aug 1, 2014

I have a short subroutine to delete a row in a second worksheet (SUMMARY EXPENSES) if one is deleted in the main worksheet (AS CODES) as per below:

[Code] .......

In theory the row deletion should only be triggered IF dynamiccounter is smaller than staticcounter, but the fact is anything whatsoever triggers the row deletion. If I type text into a cell a row gets deleted. If I copy a cell, a row gets deleted. It works great at deleting the line, but I suspect it has nothing to do with the counters I set up and the reassigning of the counter value towards the end of the If statement.

View 4 Replies View Related

Delete Worksheet Private Sub After Paste

Mar 20, 2014

I have a worksheet with a bunch of formulas in it. Computations are done on the worksheet and then I start a macro that copies the sheet and replaces the calculations with values.

The worksheet has a sheet level private sub.

View 6 Replies View Related

Delete A Worksheet If Exists Or Present

Jul 27, 2009

How do I delete a worksheet but ONLY if it exists, if it doesn't exist, ignore the command. I'm afraid to mess up the other code in the macro/sub, so here it is...

View 2 Replies View Related

Loop Through Worksheet Delete Row Until Specific Value

Jul 8, 2009

I'm trying to loop thru the worksheets(which are imported from a web form in Outlook) and delete row 31 until the text "PARTS" is reached.
I need to do this to format each sheet exactly for export to an Access database. The code below works when I step thru it but when I save and run from a button it gets stuck in an endless loop. Any help would be greatly appreciated.

Sub DeleteRow31()
Dim w As Worksheet
Dim rng As Range
For Each w In Worksheets

Do Until Cells(31, "B") = "PARTS:"
If Not Cells(31, "B") = "PARTS:" Then
End If
Next w
End Sub

View 9 Replies View Related

Delete Code From Worksheet Module

Dec 13, 2006

how to write a procedure to delete macro code that is in the worksheet property? I created a and excel model for a colleague which had many macro procedures including "Worksheet_Activate". The problem is now this individual moves the worksheets into new workbooks and this is cause many runtime errors. Is there a way I can write a copy/move procedure that also deletes the Worksheet Activate macro so that error does not appear?

View 2 Replies View Related

Macro Which Saves Data From Temp Worksheet To Customers Worksheet?

Mar 17, 2013

Dropbox - Final.xlsm

Here is the above link. Am looking at a button which saves whatever is the temp worksheet row in the customers worksheet. The temp worksheet basically takes the data from the Quotations worksheet and places it in a row.

View 9 Replies View Related

Copyrights 2005-15, All rights reserved