Macro To Delete Itself
Jan 9, 2007I have a macro that I would like to remove itself from the file as its last action. I don't want a warning message re file containing macros to show on opening the file.
View 9 RepliesI have a macro that I would like to remove itself from the file as its last action. I don't want a warning message re file containing macros to show on opening the file.
View 9 RepliesI 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.
Sheets("Tel").Select
ActiveWindow.SelectedSheets.Delete
I have recently grabbed the very helpful "Macro to delete VBA code" from this site, and it's working but with one small problem.
My worksheet runs a lot of code, then deletes all macro code and saves itself.
The problem is the next time i open I still get the macro security warning!
I've checked thoroughly and there is definatley no vba left anywhere.
If I open the document, enable macros, and save it, then open it again, I no longer get the warning.
I have date from column a to k
I have a formula on column L
I want macro to delete all rows with #N/A
Need a macro for the following situation, will be incorporated into my other macro.
For each row in column C,
if value for first 4 letters = "abc " or "def " or "ghi " or "jkl " then delete entire row.
I'm looking for code that will prompt a user to select column(s) to be deleted.
- With the exception of columns A,B,C.
- Only entire columns can be deleted
- Rows can not be selected for deletion
I want to delete a row if it contains componenten.
In here i ask to delete componenten not.
Or should i take "*componenten*" or totaly someting else
For MY_ROWS = Range("c65536").End(xlUp).Row To 1 Step -1
If UCase(Range("c" & MY_ROWS).Value) = "COMPONENTEN" Then
Rows(MY_ROWS).Delete
End If
Next MY_ROWS
Have a sheet that has a $ value in Col J would like to run a macro that would delete the Row if the value is $0.00 and move the rows up.
View 9 Replies View RelatedOn a daily basis I populate data on different worksheets. Meaning on each day I have to delete T-2 data to populate T-1 data.
I would like a macro to select a date to delete rows from each worksheet containing the date in Column A of each worksheet
I experimented with a simple macro in a worksheet template, but decided not to keep it and deleted the macro. However whenever I add the template to the workbook, it still asks about the macro and whether or not I want to enable it.
When I go back to tools/macro to delete it, there is NO macro that shows up in the dialog box. Why is the workbook still asking me to enable a macro I deleted?
I am running some macros, but at the end of the macro running i want it to delete itself.
View 4 Replies View Relatedi wrote this macro and want to delete last two rows on active sheet this macro.
Sub deleteLast2Rows()
With ThisWorkbook.Worksheets(1)
Dim rowNum As Integer
Dim m As Range
rowNum = 2
Set m = .Range("A" & rowNum)
rowNum = rowNum - 2
EntireRow.Delete
End With
End Sub
I have tried to record this but I cannot get it to work? On the tab “Add & Delete” cell “L17” I have a drop down list that is a list of the policy numbers from the “Data” tab.
What I am trying to do is assign a macro that searches column “J” on the “Data” tab based on the “L17” content on the Tab “Add & Delete” when it finds the data it then clears the contents of that entire row.
I'm using following code to delete some image called "Dev_Graph"
Sub Del_Graph()
'
' Del_Graph Macro
Sheets("Report").Unprotect Password:="1234"
ActiveSheet.Shapes.Range(Array("Dev_Graph")).Select
Selection.Delete
Range("B11").Select
Sheets("Report").Protect Password:="1234"
End Sub
the problem is, If i run this macro when there is no Image, i got a error msg.
I have a large file of data and the data looks like this repetitively, however, there are also useless data. But I figure out that the repeat data looks the same compare to the useless data. I need to extract the data that I only need. Is there a way to set a macro to search for a String from the beginning of the excel file, when the string is found, it will keep the 2 rows above and 56 row below it, then loop.
Here is an example of it:
A1 USELESS DATA
A2 USELESS DATA
A3 USELESS DATA
A4 USELESS DATA
A5 GOOD DATA
[Code] ....
The macro will start from A1 then go down till find STRING, then will keep 2 row above it which is A5+56 row below it which is A63.
Then continue at A64, then find STRING at A66 and do the same which is copy A64 (2 row above)+till A122 (which is 56 row below), then continue.
Since A123 to A155 does have any STRING, they will all be deleted..
I have a huge spreadsheet that I want to be able to sort through and delete the unwanted rows. I want to do a search for anything in column C that equals 2225 including the next row after and delete the rest. Here is an example...
View 3 Replies View RelatedCan't quite figure out how to do this. I'm looking to create a macro that will delete every other row of a filtered set of data. for example, if these are the filtered rows:
row 21
row 22 delete
row 50
row 51 delete
row 58
row 59 delete.
... and so forth down to the bottom of the filter. I cant seem to record the macro using a relative reference with the filtered data.
Attached is a sample data set. If all the positive and matching negative entries are located and removed, there are 4 remaining entries. The only pertinent columns are A through J, the columns after that are where my fiddling is occurring.
First you have to highlight all the data (including the control columns to the right). Then, my macro sorts the data by the absolute value (found in column O), allowing the formulas in N to then properly mark all negative entries with an "X and all the ones that now have a matching positive entry directly below it with an "X".
Then my macro hides all the fields with an "X" in column N. There is a macro called "CLEANSE" that does this, but only hides the rows. I keep messing up when I try to delete them entirely.
Can someone correct my macro so it will properly delete the rows with an "X" in the N column, or suggest a better macro that will scan the E column and flag matching positive/negative numbers and delete them without my control columns N and O?
This is a piece of code from a macro that i am altering. I keep getting an error when i get to the 2nd line.
View 7 Replies View RelatedShift+Ctrl+Down Arrow
Edit > Go to (ctrl+g in '97)
Special
Blanks
[OK]
Edit > Delete
"Delete Entire Row"
Short Version-Select all rows under last used cell
Excel UI "Go to" Blanks (whatever that does...)
Delete selected rows
I have 2 command buttons on a sheet, one of which I would like to upgrade to delete the other, as well as itself, upon completing the rest of its functions. That's right, normal VBA isn't fun enough anymore, I want kamikaze suicidal code that wipes itself off the face of the earth.
My colleagues are... less than comfortable with VBA. I use it to produce some of the forms which I send to them, and if I could delete the code automatically after running, I'd save myself some time and/or save them some confusion.
I have got the macro below, my problem is that when you run it, it takes 20 seconds or so. In my other larger spreadsheet it was almost instant.
View 4 Replies View RelatedI am trying to find a macro that deletes a row that does not contain a given word or string.
For example, if a row does not contain the string -> then delete it or even better select and move all such rows to another worksheet so that the main worksheet is left only with rows containing the string.
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
I would like to detect when the user uses the "DELETE" key and would like to run a macro at the same time.
how to detect it and run a macro in VBA.
I am going to record a macro to clean up a report but the first thing I need to do is delete rows that contain dates before July 17, 2012. The dates are in column B. Is this possible in the macro?
View 5 Replies View RelatedCurrently have a sheet that allows me to pick an item from a drop down list and show me the code for that item.
I already the macros for adding an item to the list via a add button. All this dose is if the item is not on the list i can simply be added into the two boxs and then click the add button.
What i want to do is add a delete button. This is in case someone enters the values wrong then can select it in the list and then click the delete button.
So all i want is to look at the item cell, match to a range and delete the row.
I have added a link to what it looks like as well as the coding i have used so far. [URL] ........
Sub Add_to_list()
'
' Add_to_list Macro
' Adds new item to list
'
'
Range("F10").Select
Selection.Copy
[Code] .......
create a macro that will delete tabs that ends with the word "OPEN" from a workbook?
View 9 Replies View RelatedIf column B contains the word FALSE, I need to delete that entire row, then I need to repeat this action on 11 sheets out of 14 on one workbook, in one action.
View 6 Replies View RelatedI recorded this macro but I need it to delete any Rows that have the word "Normal" in column F
Sub Count()
'
' Count Macro
' Macro recorded 5/22/2007 by pricci
'
'
Sheets("Alarm Log").Select
Sheets("Alarm Log").Copy After:=Sheets(2)
Sheets("Alarm Log (2)").Select
Sheets("Alarm Log (2)").Name = "Count"
Cells.Select
Selection.Sort Key1:=Range("F2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub