Excel 2007 :: VBA Code To Delete Rows Based On Text Starting Content

Oct 25, 2013

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 would only like to keep the last 3 lines.

View 3 Replies


Excel 2007 :: Option To Have Row Heights Set Automatically Based On Content Of Text In Row

Sep 28, 2012

Is there an option to have row heights set automatically based on the content of the text in the row, and given a specific column width?

I can right click, and set each row height individually.

I can select serveral rows stacked one on top of the other, each with limited text, and change all of those rows at the same time.

But when I select all rows, and try to change row height, the row height option is not there.

View 2 Replies View Related

Delete Rows Based On Content

Jan 5, 2009

Can a macro be used to:

1. Delete rows that contain certain text in a worksheet ?
2. Highlight a cell a colur based on a response ?

I have attached an example of what i mean .....

In the Audit Protocol worksheet is the main information - which contains questions and answers .... If a yes, n/a or no is selected then a response is automatically generated in the observations column (thanks to SHG for helping me with the formula for this) ..... How do I then get the cell to change to red if a NO response only is selected ?

Then the information from the Audit Protocol worksheet (the observation column and number column) are copied across to the worksheet named Action List (this is done just by the copy function) .... How do I go about deleting rows that contain "no action required" - as these are not needed for the report to be generated ?

View 11 Replies View Related

Excel VBA Code To Select A Range (rows) Based On Values And Delete

Aug 8, 2013

I am trying out with a code which checks for cell value as "Select" in column IU and then checks for corresponding column IV for value as "0". Please note that "Select" and "0" are populated by formulas. I need the select "Select" and "0" till the next "Select" occurs in column IU and delete the selected range and continue the process until last non empty cell based on column C.

I have written the below code but it doesn't work.

Public Sub Test()
Dim nRow As Long
Dim nStart As Long


I could have uploaded the excel file that I am working on but did not find any upload attachment option.

View 1 Replies View Related

Remove Cell Content Based Upon Not Starting With A Word

Jun 16, 2008

I am working on a macro and, as part of it, I would like to look at column A of my spreadsheet and remove all cell contents where the text in the cell does not start with the word "total." For instance, if the text of a cell in column H is "total money" I would like it to remain unchanged. However, if the text of a cell is "George Baker" I would like it removed. I ONLY want the text in column H to be considered ... no other column.

View 3 Replies View Related

Excel 2007 :: Delete Red Rows Only

Aug 13, 2013

I have a large file with a bunch of color coding and need to delete my red rows only.

View 3 Replies View Related

Excel 2003 :: Deleting Or Displaying Rows Based On Cell Content One By One

Mar 20, 2014

I have a company with upto 5 products, and I have created a dropdown box where you select your product.

When I select product 1 i would need info on product 1 , when i select product 2 I need info on product 1 and 2 and continue. so for product 5 -i need info on product 1-5.

I tried to add all info on excel and tried to delete it one by one by deleting rows in excel for products but it does not work.

View 4 Replies View Related

Code To Delete Rows Based On Status Code In Column

Jul 24, 2009

I'm trying to write a VBA script which will delete all rows in my Excel spreadsheet where Column I (which contains a status code) does not contain the word "Completed".

At the moment, I'm doing this the other way round: my script is able to search for entries in Column I which contain the status codes "Pending", "Awaiting Authorisation", "In Progress" etc and delete them. The idea is that when all those rows are deleted, I'll only be left with rows which have a status of "Completed". This works fine at the moment. However, the concern is that if a brand new status code is added to the data file, my script would be unable to pick it up and delete it. This is a small sample of the code I'm currently using (which deletes all the rows with statuses other than Completed):

View 4 Replies View Related

Excel 2007 :: Delete Rows If Value Is Found In Column S

Jan 23, 2012

I'm using this code to find values of "FEP MHS" or "LSD MHS" in column S and if column S containes either of these values it deletes the entire row from the spreadsheet. I need this to work on a spreadsheet that runs on a daily basis and each day it contains a different number of rows. I have used this code to successfully delete most rows that contain these values in Column S but for some reason it does not delete all the rows, typically leaving 6 - 7 rows that contain these values. I'm using Excel 2007 I need code that finds the last row used and deletes the entire row if these values are present.

Set RngRSLHMHSD = Columns("S").SpecialCells(xlConstants, xlTextValues)
For iRSLHMHSD = RngRSLHMHSD.Count To 1 Step -1
Then RngRSLHMHSD(iRSLHMHSD).EntireRow.Delete

View 1 Replies View Related

Excel 2007 :: Move Data From Multiple Rows To One And Delete?

May 2, 2012

I'm working in Excel 2007 and need to move data from multiple rows to a single row if the ID matches.Below is sample data I would be working with. I want to move data from columns F-U to the right of the original data in the row above it. I would also like to delete the rows that had data moved.

GIDSurnameNameEmployee Number OriginalDate of birthGranting ARE
Employing ARECountry Employing ARECHCM Supplier IDVehicle
Investmt. shares / Awards at termination dateMatching Shares
at termination dateTermination


View 3 Replies View Related

Excel 2007 :: (Cannot Complete Task With Available Resources) When Trying To Delete Rows

Jul 11, 2012

I have VBA code that attempts to delete an entire row from my worksheet:


This works fine on small data sets, but on larger data sets it gives me the error message, "Excel cannot complete this task with available resources". This happens even when I try to do the deletion manually (without VBA code). Clearly, the code itself is not the problem.

My document has about 250,000 rows and 2,500 columns. While this is big, it is significantly smaller than Excel's documented limit of 1,048,576 rows and 16,384 columns.

I am using Excel 2007. My computer has 2GB of RAM but even when I try it on a computer which has 8GB of RAM it gives me the same error. If I "ClearContents" instead of "Delete" it works fine. For my purposes, however, deletion is entirely necessary.

View 9 Replies View Related

Delete Row Based On Starting Character 1st Then Contains

Jun 23, 2007

I would like to create a macro that deletes all rows starting with an open parenthensis in column B. The contents of what is in parenthis varies from 2 letters up - so anything starting with a parenthis is sufficient criteria.

After the initial deleting (mentioned above), would also like to delete (from column B again), rows containing specific, multiple phrases.

None of the functions I have see so far will facilitate this...

View 9 Replies View Related

Code To Delete Rows Based On Condition

Apr 24, 2009

I have an Excel spreadsheet that is given to me weekly, but I'd like to remove repetitive and empty rows before presenting it to someone. It is set up like this:

Row 1, A1, contains the word Project.
Row 2 is blank
Row 3 is blank
Row 4 is blank
Row 5, A5, contains the word Organization.
Row 6 is blank
Row 7, A7, contains a 6-digit number starting with 3.
Row 8 is blank

(all of the above starts over again (loops) approximately 30 times)
The final row contains the phrase "Grand Total"

*Row 5 is repetitive and is not required. I'd like to delete it.

I have too many empty columns. Getting rid of them (and Row 5) would greatly shorten my spreadsheet.
I am aiming for:


(Repeat until finished)

Grand Total:

View 4 Replies View Related

Code To Delete Rows Based On User Input

Aug 21, 2008

I am using the following piece of code to delete unwanted rows from a worksheet:

Sub DeleteDates()

FinalRow = Cells(65536, 3).End(xlUp).Row
For i = FinalRow To 1 Step -1
If Cells(i, 3).Value Like "*2007*"
Cells(i, 1).EntireRow.Delete
End If

Next i

End Sub

What I am working with is a sheet of about 5000 customer appointments going back to the beginning of 2006. A have peiced together a lot of code to format it exactly as I want and to create a pivot table of what is remaining after the rubbish has been deleted.

However I am finding that I need to keep amending and re-running this bit of code, depending on the date range I want to look at. For example the code above will delete all appointments made in 2007.

My question is: is there a way that I could incorporate an input box, whereby excel asks the user for a start date and an end date and deletes any rows outwith that range?

Some important info: All of the dates are in column C, in the format mmm yyyy

I would only need to narrow down to a month - so for example mar 2008 - jun 2008

View 9 Replies View Related

Modify And Enhance Recorded Code - Delete Rows Based On Value

Aug 22, 2012

I searched many sites and used codes which delete Rows based on criteria. In my case those codes works, BUT it took so much time about 30 min since there is about 75 thsd rows, and that solution in not time saver. I recorded code below and it is done in seconds. make it dynamic, VBA, since number of rows is every month larger. Basicly, I need code which delete rows based on Column B, where walue is "R"

Sub DelRowsBasedOnOneCriteria()
' DelRowsBasedOnOneCriteria Macro


View 4 Replies View Related

Deleteing Rows Starting With Value (text)

May 22, 2006

Using an external UNIX program that quieries a database, I export all the data found based on my query and export the report as a text file. THe text file can be up to 1 MB of raw text.

Selecting all text and pasting the data into collum 1 using PASTE SPECIAL -->(TEXT)

All Data is in Collum A

Each record returned has between 40-50 values each on a seperate row, only 10 of which I need.

I am looking for a way to find the rows that begin with the unwanted field, and then delete the entire row.

Otherwise ignore the row.

AUDFI : (data path loc here)
BILLNUM : 060606
CUTNUM : (0000)
SD : 120012
ED : 121259
COMMENT : Multiple lines of text here
with continuing free form data, numbers, operators,

then the next data file would repeat:

ADUFI : (data path loc here)

In the above example, I want to delete the rows AUDFI, & CUTNUM and move the below items up to take the empty rows place. The BILL NUM, SD,ED, and COMMENT are filed that are always kept (as well as others). Each record has roughly the same data, each tailored to an event or object.

The number of rows of data dumped into excel can easily exceed 50000, about 200 - 1500 records in the report.

After wards, the data is dumped to a text file for easier analysis.

In BASIC my line might look like
10 if A:$="AUDFI :" then delete row, move below contents up.
20 if A:$="CUTNUM :" then delete row, move below contents up.
30 END

(I think there needs to be a loop since the vaules AUDFI and CUTNUM (as well as other unwanted fields can occurr 200 - 1500 times each.)

View 7 Replies View Related

Excel 2007 :: How To Duplicate Rows Based On Cell Value

Feb 26, 2014

What im needing is something that will duplicate each row based on Column F as shown below... However I also need the duplicate row numbers added to Column G and then the original row deleted... I will try and show you an example of the input/output i would like to achieve: (also the first row can be ignored it will all be headers)




View 1 Replies View Related

Excel 2007 :: VBA Code Determine Where To Paste Based Upon 2 Cells In Different Workbooks Being Equal

Feb 24, 2014

Trying to manipulate a macro I recorded to be slightly more dynamic with some VBA code. The macro has saved me a lot of time however each month I have to re-do it due to the date changing and I'm sure there must be an easy way to adapt the below code.

Current Code (it repeats afterwards as there are lots and lots of sheets I need to perform the action on).

Windows("Raw Data.xls").Activate
ActiveWindow.DisplayWorkbookTabs = True
Windows("Volume Tracking.xlsm").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

What I'm after is a way to alter the range highlighted based upon matching a cell in "Raw Data.xls' and a cell in "Volume Tracking.xlsm".

The cell A43 in "Raw Data.xls" contains a month (which changes every month); if the month is Jan then I would want the Range to remain as AE33. If it's Feb then I would want the Range to be AF33 (and so on).

In "Volume Tracking.xlsm" I have the months in cells AE4 (Jan), AE5 (Feb) etc.

Is there a way to locate the column in "Volume Tracking.xlsm" on row 4 that contains the value found in A43 in "Raw Data.xls" and then paste what was copied out of "Raw Data.xls" C43 and paste it in to row 33 of the correct column that holds the matching month?

If not could I add code to say if cell A43 in "Raw Data.xls" = Jan then paste to AE33, if Feb then paste to AF33 and so on.........

Excel 2007

View 9 Replies View Related

Delete Rows Based On A Text Criteria

Aug 24, 2009

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?

View 8 Replies View Related

Excel 2007 :: Format Rows Based On 1st Cell Populated?

Nov 16, 2012

I am using Excel 2007

I am trying to conditionally format rows based on the first cell in each row. I had this working in a previous worksheet and have gone through several examples based on answers in other threads but do not for the life of me know what I am doing wrong. I am using the conditional formating rules on the ribbon menu.

I have a range A3-W100 pre-formatted with generic data and formulae. Column A has no data. I want the text to change color for that row if the cell in column A is populated. The background and text are set to black to appear unpopulated.

When an item number is entered in column A3, the text color in row 3 changes to white. I can get this to work on one row but if I extend it through the range, all rows change. I want them only to change if the respective A cell is populated.

I am using
Formula is =A3>""
Format is Yellow,
Applies to =$A$3:$V$100
Stop if True is unchecked

All I can get is column B to change color.

View 6 Replies View Related

Macro To Delete Rows Based On Partial Text

Apr 9, 2009

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.


the numbrs in these cells increment therefore I can not make it a specific to the cell but need to select based on Booklet, Lotto and PBT.

View 5 Replies View Related

Excel 2007 :: Macro To Insert Rows Based On Cell Values

Dec 19, 2013

a macro to insert rows based on certain cell values in column A.

I have uto 300 rows of data. Below is an example of column A.



If (above the R) is an 8, I need to insert 2 rows above that R and directly below the 8.

If (above the R) is a 9, I need to insert 1 row above that R below, directly below the 9.

(Below the R there is always a minimum of 8 digits with the 9 and 10 being random).

I have excel 2007

View 5 Replies View Related

Excel 2007 :: Copy / Paste Based On Font Text?

Dec 2, 2011

Have a HUGE excel 2007 sheet of over 1500 rows that looks like this:


I need to get it to look like this:


[Code] .......

In other words, I need to copy the text in blue so that it is above the text in black and the text in red so that it is below. Then I need the macro to repeat this procedure for each cell that it finds containing text in black. I have already created and run a macro to insert blank lines between each black text entry.

View 7 Replies View Related

Excel 2007 :: Grabbing Format Of Cell To Use Content?

Jul 11, 2012

I have a file which included monetary amounts in many currencies, which appear in Excel 2007 as:

232.44 EUR
103,796.10 CZK
18,071.08 PHP

I need to use the value and currency code, but unfortunately the currency code is part of the cell format (so I can't use, say =right(3) to grab it.

The cell format is set to: #,##0.00 "EUR" , with each cell set according to the currency within.

Of course I will be going back to the source to see what I can do to get something more useful directly, but is there any way I can grab the currency code so I can use it ?

View 1 Replies View Related

Excel 2007 :: Found Unreadable Content In File Name

Sep 10, 2012

I have a problem with the Excel 2007 file which I use on Windows 7.

The file suddenly appear message:

Excel Found Unreadable Content in 'File Name'. Do you want to recove the contents of this workbook? if trust the source of this workbook, click Yes.

if I click "YES" than this message will appear:
Excel was able to open the file by repairing or removing the unreadable content........ and so on

And all the file is missing inside the sheet.

Any way out to recover this file?

View 1 Replies View Related

Excel 2010 :: VBA Code To Search Multiple Columns And Delete Any Duplicate Cells (not Rows)

Jun 12, 2014

My Excel program (Excel 2010) currently has several columns and each column looks for and pulls data from a specific file on my computer. Then I need to delete any duplicate data entries, count the number of unique entries and track the changes through a chart. I have everything done except I cannot figure out (or find on the internet) a way to search in multiple columns (more than 2) and delete just the duplicate cells. I want to delete the cells in a way where there is one left. For example if the code 12gf is duplicated three time, I want to be left with one 12gf (it doesnt matter what column the original one is left in). Additionally, column length changes and they are not sorted. I have attempted to attach an image of an example file below.

View 14 Replies View Related

DELETE Row Based On Content Of Column

Jan 8, 2008

Need macro or other code that will examine a column in my my table for particular text (example: find text: "Total") and then DELETE the whole row that the cell containing the text is in.

View 9 Replies View Related

Delete Cells Based On Content

Feb 3, 2010

I have this:

Sub CompileData()

'Dim rng1 As Range
'Dim rng2 As Range

'Set rng1 = Worksheets("Sheet2").Range("A4").End(xlDown)
'Set rng2 = Worksheets("Sheet2").Range("C4").End(xlDown)
'Set AllRng = Union(Range("rng1"), Range("rng2"))

Now when its pasted it has cells with "Nil" in it. I need to delete them, or just not copy them over.

View 9 Replies View Related

Excel 2010 :: How To Delete Rows Based On Cell Value

Sep 23, 2011

I have a massive spreadsheet (ca.110 000 rows [excel 2010). I need to cut this monster by deleting all the cells that do not have a certain cell value within them.

Say that in my column A there are different entries (text type). I would like to delete the ones that do not match the following criteria:

"mytextascriteria*", where * somehow stands for the rest of the string.

Strictly speaking I can only determine beggining of the string I want to perserve but the values at the end of that string are changing.

I found the thread about deleting entire row based on a cell value here:
Delete entire row based on one cell?

but I couldn't quite work out how to apply it in my scenario....

Otherwise is completely pointless to do it manualy with these amout of records.

View 5 Replies View Related

Excel 2007 :: Looping Through Text Strings And Copying Based On Criteria

Sep 17, 2012

I have 2 excel files, let's call them 1.xlsx and 2.xlsx (excel 2007)

File 1 is the file where I want data copied into and file 2 is the file I want to copy data from.

File 1 has certain text strings in every say 5th column in always row 2. I want to find those strings in file 2 and if the string is found, go 6 rows down, copy the cell, and paste it into file 1, 8 rows down the text string. this is the code I came up with, but it doesn't work

Option Explicit
Sub get_data_from_2()

Dim i As Long
Dim j As Long
Dim FinalColumn As Long
Dim RngFrom As Range

[Code] .......

the bolded part gives me an error.

View 3 Replies View Related

Copyrights 2005-15 www.BigResource.com, All rights reserved