Delete Rows Containing Text With A Certain Suffix?
Aug 1, 2013
Each day I recieve a spreadsheet with thousands of row. In col A there is data that has "-NCA1" or "NCA2" as the suffix. I have to "delete" these rows before proceding.
I'd like to know if there is a way to do this with a macro and ideally delete a wildcard suffix with "NCA*" in case any 3...4..5 etc are added.
I'm trying to write a line of code in my VBA macro that goes through all of column B and if there is text in the column to go to the next cell down and if there is no text to delete the entire row. I have the bricks I just cant build the house. I need the macro to do this for rows 8 to 500.
I have a spreadsheet which is created 2/3 times daily and I need a macro to do the following;
The columns are A To AJ, I need to delete all columns with the exception of columns M, N, R
Column M contains currency (GBP, Euro) Column N contains dates Column R contains various agent log ins, such as LI111222AB, LI222111JM, IFCTest & HOTAYLORL
The row number can vary (Average 1,000), I need to delete all rows that do not contain a log in which begins with LI in column R
Once this is done, subtotal by column R (agent log in), column N, & column M
What i'd like is a macro that will delete all cells that don't contain the word pagelibrary somewhere in the cell. As these are weblogs, pagelibrary can be in many different places in the link due to redirects etc, so the macro would have to be flexible with that word. All cells are only one column, in column A. Also if it is possible to delete everything before the word pagelibrary that would be helpful as well as some of these links are very long (and possibly duplicates due to capitalization and redirects).
I've done some searching and this code is the code that closest matches what I want to do. I am by no means a VBA expert; I can decipher a little of what code does, I just can't write it .
Sub DeleteRowEqualTo() ‘Hold Shift Key To delete rows Not equal To
Application. ScreenUpdating = False Dim currentRow As Long Dim lastRow As Long Dim activeColumn As Long
Dim activeValue As String Dim currentValue As String
I am trying to write a code that would remove rows with any sort of letters in them. I have looked up other ways of deleting rows, but I cannot find the script that would encompass all (alphabetical) letters.
I have put together a macro that will delete rows (called DeleteUnwantedRows) in a spreadsheet that contain the phrases "no further action" and "not applicable" ... However the macro does not appear to be working.
how to use a macro to delete rows that have text in them. I have an imported text file that has headings every 10 rows and I need to take out the heading rows
I have a spreedsheet that has both numerical data and text data in column "A". I need to delete all the rows that have text in Column A and keep the rows that have numerical data.
I have a report that comes in a txt file. After importing into excel i am left with a bunch of garbage that i dont need. This report is anywhere from 5-15 pages depending on how much product was made that shift. I only need the information off of the 1st page. My question is how can i Find the first occurance of specific text (Site) (will be in column A) and have it select that row and all rows below and delete them. My biggest issue is the first page can be anywhere from 40-60 rows so I need to find the text (Site) and delete everything below it, which could be anywhere from 500-1500 rows.
I have a sheet with data only in column A. I want to remove any rows that dont contain the word MAR. All the lines with MAR in start with: CN=GR GG COF MAR **** macro which would do this as i have over a 100 sheets. and maybe an explanation as i am totally new to this?
Here is what Im trying to do: I have a VERY large excel file that has groups of 4 cells, a blank, then another 4, repeating. Kinda like the following:
ExampleCell1 ExampleCell2 ExampleCell3 UID = example
ExampleCell1 ExampleCell2 ExampleCell3
ExampleCell1 ExampleCell2 ExampleCell3 UID = example
That pattern continues for about 3000 lines. However, if you noticed, some of the "groups" dont have the 4th line "UID = example".
Here is what Im trying to do. I want excel to search for the cells with "UID" and DELETE it plus the 3 rows above. So that only the "groups" without the UID remain.
Now Im thinking this may be impossible, but I've seen some crazy things done with excel macros and was really hoping someone can help me out. Otherwise Im doing this manually for 3000+ lines of text.
I am trying to figure out how to have some VBA look down Column 1 and where the Cell's string value = "GRANDTOTAL", to DELETE that ROW and ALL ROWS below.
Can anyone help me out in writing the Visual Basic code?
i am importing a large number of text files from a folder into an excel worksheet (into column A) and found the following code from searching the forum.
Sub Import_Text_Files()
Const PATH = "C:Documents and SettingsSilent BazMy DocumentsElectronic Gift Card WorkTestTextFolder"
Dim My_Filenumber As Integer Dim My_File As String Dim My_Data As String
My_File = Trim(Dir(PATH))
If My_File = "" Then MsgBox "No Files found matching " & PATH & My_Extension Exit Sub End If.......
I want to delete any/all rows from a worksheet (named UK) which have the word "VAN" in column P. I have tried using a 'For Each... Next statement' in a macro, but always get a debug box "Run Time Error '91' Object variable or With block variable not set". What am I doing wrong? my code follows
Sheets("UK").Select Dim cell As Range For Each cell In Worksheets("UK").Range("P10:P200").Cells Cells. Find(What:="VAN", _ After:=ActiveCell, _ LookIn:=xlFormulas, _ LookAt:=xlPart, _ SearchOrder:=xlByColumns, _ SearchDirection:=xlNext, _ MatchCase:=False, _ SearchFormat:=False).Activate Selection.EntireRow.Delete Next
I am looking for a macro to delete entire rows based on the a partial text contained in column A. For example, I have a list of names that I need to keep but I need to delete the rows in which column A contain cells starting with the following.
I need a VBA macro that deletes whole rows if the cell in one of the columns does not match one of three texts. For example, in column B, if the text in there isn't "Mary", "Joseph", or " " (empty space), the row must be deleted.
I have data that covers multiple rows that I need to merge into one row.
Header:| InvoiceNumber | Type | Name Row1: | 1000 | Payor | Doe, John Row2: | 1000 | Payor | Smith, Mary Row3:| 1000 | Payee| Jones, Henry Row4:| 1000 | Payee | Jones, Bob
I need to get those four example rows down to one row such as:
Header | InvoiceNumber | Payor | Payee Row1: | 1000 | Doe, John & Smith, Mary | Jones, Henry & Jones, Bob
The number of payor/payee can vary between 1 and several. I need some way to loop through and keep appending the names in one cell separated by a "&". And then deleting all the duplicate rows (based on InvoiceNumber).
I have around 50 text files with similar design per attached file. I need to import the text files with criteria below:-
1. include file name 2. let user choose the folder 3. exclude data from "work in process summary" to "work in process cost totals" 4. only have one title in the excel files which all text files is combined "Item, Line ....." 5. If the text files do not have title like "Item, Line, ..." do not import
Is it possible to have all criteria listed above by running a macro?
Using excel 2007. I am interested in writing a VBA code to delete rows based on the text starting content. I would like to delete rows with cells that do NOT start with an "S" or "SA"
I want to generate a text column for a mail merge which will add the correct ordinal suffix to dates eg st to 1 as in 1st or 21st or 31st but nd to 2nd 22nd also rd and th where appropriate.
I have a macro that will add the next letter to a number as a suffix but this will only work for A - Z. But i need variations of upto 150, so i need the macro to add another letter to the variation once Z has been reached. For example at the moment 1000A the next variation would be 1000B up until 1000Z but once this has been reached the macro then starts to use symbols as the code is written using ASCII numbers. So i need the next variation to be 1000AA then 1000AB etc the code i currently have is
Public Function NewVarianceLetter(lngQuoteNum As Long, Optional rngQuote As Range) As String Dim a As String Dim i As Long Dim rngFind As Range
I find, when performing a 'save as', xl puts in a default filename with a suffix (1), or (2), or (3) and so on, to the existing filename, after I have opened a file from MS Outlook. I had assumed it was because there was already an existing file in the default directory, and so it was creating another version, but no other files with the same name exist in the default directory being saved to, or on the remainder of my computer, so I don't understand why this occurs.
I have a piece of code that runs and creates an output Excel sheet that currently has the run date as a suffix for the automatically generated file name. However, I now sometimes have to run this report multiple times in one day, which currently means overwriting the previously run spreadsheet (whereas I would like to keep both versions of the ruin output).
Is there a way that I can create some kind of counter for the number of times the report is run and add that as a suffix for the file name? At the moment the only way I can think to do this is to set up code that looks at the file name containing the date field and adds 1 to every number that is added as a suffix, but this doesn't seem very efficient...
I am using (in Column "B") the formula: =IF(A2=A3."",1), copied down as required, to uniquely identify entries in Column "A". In this instance "10", "10A", "10B" and "10C" located in "A5" through "A11" are viewed as the same. Is it possible to have the formula recognize the enties in "A5:A11" as a unique entry and therfore have "1" entered into cell "B11"? The suffix, if used will always be A thorugh Z.