Delete Unwanted Rows Based On Value In Cells?
Sep 28, 2011
I am aware this is probably very simple, but I haven't been able to find a usable macro yet. I would like the data in the workbook that is not "Tuesday" (column L) and is not "3" or "4" (column I) to be deleted. All rows that have "Tuesday" and either "3" or "4" should not be deleted. Each row that is not deleted must have Tuesday in column L. All other cells are blank intentionally. The workbook will remain the same titled WKBK1 (no need to put the output data in a separate workbook nor separate spreadsheet).
Do you know what the macro would be so I don't have to copy and paste a formula over a large number of cells?
WKBK1
A B C D E F G H I J K L 2
3
[Code]....
View 8 Replies
ADVERTISEMENT
Jul 11, 2008
1. In excel Sheet how to delete the unwanted rows in a proper way
In the following Data :
Day Date A/c Time Code Description
Tue 08/07/10 1708 02:54 E301000 > AC Loss [ri 0: Residence]
Tue 08/07/10 1708 02:55 R130006 > Reset [ri 0: Residence]
Tue 08/07/10 1708 02:56 R301000 > AC Restoral [ri 0: Residence]
Tue 08/07/10 1708 03:00 E301000 > AC Loss [ri 0: Residence]
Tue 08/07/10 1708 03:40 R301000 > AC Restoral [ri 0: Residence]
Tue 08/07/10 1708 04:08 E301000 > AC Loss [ri 0: Residence]
Tue 08/07/10 2410 04:23 E301000 > AC Loss [ri 0: Residence]
Tue 08/07/10 2410 04:47 R130006 > Reset [ri 0: Residence]
Tue 08/07/10 2410 05:56 R301000 > AC Restoral [ri 0: Residence]
Tue 08/07/10 2410 06:21 E301000 > AC Loss [ri 0: Residence]
Tue 08/07/10 2410 06:30 R130006 > Reset [ri 0: Residence]..............
View 9 Replies
View Related
Oct 8, 2007
I am using the following code to filter for data I do not want and then to delete those rows and show remaining data. It works fine except when the filter comes up empty and there is no unwanted data to delete.how to improve this code to accomodate this situation?
Selection.AutoFilter Field:=4, Criteria1:=">" & dweekend, Operator:=xlAnd
Range("A2").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.EntireRow.Delete
ActiveSheet.ShowAllData
Thank you for reading
View 9 Replies
View Related
Oct 25, 2012
I'm trying to filter and delete unwanted rows as I need row where dates is within a specified range.
How can I do this using AutoFilter? or are there any other alternatives?
View 2 Replies
View Related
Dec 30, 2011
I want to delete some unwanted rows on closing my excel file. the blank rows are between set of datas. so it has to check all the blank rows, delete it until the last one. example
data
blank rows
data
blank rows
data
blank rows
data
View 4 Replies
View Related
Apr 20, 2012
ItemNew or UsedQuantityDescriptionScrap ReasonActionitem1new1000item1 description1item1 reason1item1 action1item2new1200item2 description1item2 reason1item2 action10000item2 reason2item2 action20000item2 reason3item2 action3item3used3500item3 description1item3 reason1item3 action1000item3 description2item3 reason2item3 action2
The above was imported to Excel from another software and somehow those unwanted rows with "0" were created.
Would like to delete those unwanted row and combine the reason on those rows into their respective rows above.
Please note: this is just a small part of the file. The file is big and row with "0" doesnt occur in a prodictable patten.
View 9 Replies
View Related
Mar 18, 2014
My spreadsheet has 600rows and the vertical scroll bar ends at row 459424. I have attempted to delete all of the extra rows by holding SHIFT and CTRL, striking the down arrow then right-clicking on the left margin of highlighted row numbers and choosing delete.
But the unwanted rows are still there and my vertical scroll bar is not correlated to the 600 rows.
View 1 Replies
View Related
Apr 3, 2013
I am simply trying to delete all rows that have a value of less than 16 in the cell value's first 2 characters (column G).
Start with:
18N
18K
16K
16K
16K
14L
14L
13L
12L
End with:
18N
18K
16K
16K
16K
The code I am using:
Sub DeleteUnneededRows()
Dim c
For Each c In Worksheets("Sheet1").Range("G1:G500").Cells
If Left(c.Value, 2) < "16" Then
c.EntireRow.Delete
End If
Next
End Sub
but it is not working.
View 7 Replies
View Related
Aug 8, 2008
I would like a macro that deletes rows based on having two blank cells in adjacent columns. I have achieved this with the following code however i need it to only delete rows below a certain row. How would i achieve this?
Sub DeleteBlankARows()
Dim r As Long
For r = Cells(Rows.Count, 30).End(xlUp).Row To 1 Step -1
If Cells(r, 3) = "" And Cells(r, 4) = "" Then Rows(r).Delete
Next r
End Sub
View 2 Replies
View Related
May 7, 2012
Each week I run a report that produces over 2,000 rows. I have to manually go through and delete things, by the time I am done, there may only be 320 rows left. I would apply a recorded macro, but the report is not consistent each week. There may be more or fewer rows depending on the week.
I would like to be able to run a macro that looks in column B for a specific value and if it contains that specific value, I would like the cells to the right of it to have their contents cleared.
Next, in column C, I have...
Employee2's Name
Employee2's Number
SPACE
[Code]....
I would like to be able to delete the rows, starting from Employee 2 to just before the second SUB TOTAL.
So, all I would have left in column C is
SUB TOTAL
SPACE
View 9 Replies
View Related
Jun 17, 2014
I'm new to VBA and macros, using Excel 2010, and am trying to figure out how to delete all duplicate rows in a sheet where 2 or less of their values in column A is "1". I'd like have a script that is flexible enough to change to 3 or less if need be. I also have a header row that needs to be offset in the process.
A---B-
0--123 <-delete
0--123 <-delete
0--123 <-delete
1--123 <-delete based on this the value of column A
0--123 <-delete
0--123 <-delete
1--321
1--321
1--321
1--321
1--321
or
A---B-
0--123 <-delete
0--123 <-delete
1--123 <-delete
1--123 <-delete based on this the value of column A
0--123 <-delete
0--123 <-delete
1--321
1--321
1--321
1--321
1--321
View 5 Replies
View Related
Feb 22, 2005
I have a 'document' which shows 294 pages, I have only 10 actual pages. How
can I delete or remove the unwanted pages?
View 9 Replies
View Related
Jun 20, 2007
I have a spreadsheet that i manually edit each and everyday e.g.
A B C
EABGL/UD NDT254892
MRMR/RUS/ELQNS259762
LSL/UW/B LQNS267259
WWEX/UQ bbr263666
LWL/KL/B 270407
MYTCJ/UB NDT271774
LNL/SB/UB HLC - 271955
SMMQD/WT HLC - 269516
EACO/TN/UGBBR257827
NILVA/UC EUi273645
For everything that doesnt equal EM, LN, LW and TH in column A, everything should be deleted in column B.
For the remaining EM, LN, LW and TH, i would then like it to delete / (forward slash and all characters after this) so that this would make my life easier.
View 4 Replies
View Related
Feb 13, 2009
I am using an autofilter to delete chunks on unwanted data, by using Range(Selection, Selection.End(xlUp)).Select however it picks up the header row. Is there anyway I can either get the selection of data to select one less line, or a way to get it to leave the header line?
View 2 Replies
View Related
May 15, 2012
I'm using excel 2010. I'm working with columns of values where most of the values are numbers - which is fine, and there are some numbers that have a "p" at the start of them.
e.g. Column has 49, 52.2, p56.7, 34
OK, I want to preserve the 56.7 but I want to delete the "p". I'm thinking I've got a mental block as to how to delete the unwanted "p"s but I can't think of how to do it at the moment! My code goes as follows:
If Left(Cells(1,1),1) = "p" then
'delete the "p" and leave the remaining number in tact
End if
View 4 Replies
View Related
Aug 24, 2009
I need some VBA to delete rows that are under the value of 10 in column H and keep the rest, is there a way of doing this
View 7 Replies
View Related
Mar 6, 2013
I have a spreadsheet that only contains 1500 rows but excel acts like it is is using the full number of rows available. I have a print area defined and I have tried deleting the unwanted rows but nothing seems to work.
View 2 Replies
View Related
Dec 6, 2013
What I need to do is under Document Number (column D) is to delete the rows that do not start with "RM", "AG" or "MA"and then move the rows up.
View 2 Replies
View Related
Dec 13, 2007
Im not strong in excel, that why Im here. So:
I work every day with big amount of item numbers and lists in excel and I need some macro or code to automatically remove rows, containing unwanted text.
Example:
MEMORY DIMM 512MB PC3200 DDR
MEMORY DIMM 512MB PC6400 DDRII
MEMORY DRIVE FLASH USB2 2GB
MEMORY MINI SD 2GB W/ADAPTER
MEMORY SECURE DIGITAL 2GB
MEMORY DIMM 1GB PC6400 DDRII
MEMORY DRIVE FLASH USB2 1GB
MEMORY DRIVE FLASH USB2 1GB
So I paste the text from my database, and want to automatically delete rows containing DIMM string. How can I do it?
p.s. is there also a way to leave only the rows I want?
View 9 Replies
View Related
Mar 5, 2008
This sheet has A:K columns and 1:3212 rows. There are 'page headers' that are in the text file that I want to delete (the text file was exported from an AS400 program). The first row that starts the page header has SA341 in column 1. Each page header has 5 rows. I used this code from one of the other threads on deleting rows, but I obviously do not understand the code as it deleted all rows that contained SA341.
Sub DeleteRows()
Column_To_Check = 1
Start_Row = 1
End_Row = ActiveSheet. Cells(Rows.Count, Column_To_Check).End(xlUp).Row
MsgBox End_Row
Search_String = "SA341"
For Row_Counter = End_Row To Start_Row Step -1
If ActiveSheet.Cells(Row_Counter, Column_To_Check).Value < SA341 > Search_String Then
ActiveSheet.Rows(Row_Counter).Delete
End If
Next Row_Counter
End Sub
View 9 Replies
View Related
Jun 20, 2008
I am copying a price list from a worksheet. I currently have a script that deletes unwanted rows (products) but these products' header rows' are left. I also want to delete these text based headers. One solution might be a script that reads a columns cell value in the row(s) below and if values are missing the header row should be deleted.
View 2 Replies
View Related
Jun 21, 2006
Need to find out how I can restrict a worksheet to show only the columns and rows that I want. For example, I want to show columns A to H, and rows 1 to 25, and nothing else - I don't want there to be a column G, or a row 26, just blank grey space. I know it's possible, because I've seen it done : D . But the closest I can get to is: View > Page Break Preview, which isn't quite what I'm after.
View 2 Replies
View Related
Jul 20, 2009
Is it posibile to make a macro that automaticaly delete rows based ona a condition. Condition is to delete rows that have B column value "" or zero. For example:....
View 12 Replies
View Related
Sep 24, 2009
I have a sheet with say 1000+ rows that is a QA report of possible mistakes found in a employee rostering tool.
The report finds all occurrences where the staff member only has one coffee break rather than the two they are entitled to. However, on days where they have training, or other half day commitments, on of the coffee breaks is not entered into out tool. This means we are getting a whole lot of entries that we do not require(i.e. one coffee break error).
The tool uses icons but the cells do have a single unique character under each icon type. For example, the coffee break cells have a "T" and training cells have a "&" underneath the icon (without quotes). The staff members day is separated into 15 minute blocks and each block occupies a cell in a column. This means each staff members day spans many columns in a row (i.e. C=8am, D=8:15am, E=8:30am etc...).
What I have been trying to accomplish is to create a macro in VB code that will locate any row with both a "T and a "&" and delete it. This will eliminate occurrences that we are aware of and leave only genuine errors. There are other combination's that I would like to include also such as:
"T" "["
"T" "#"
"T" "@"
"T" "]"
The first row is headers and the first two columns contain team names and staff names which I am trying to exclude (because names contains "T"'s ).
I have spent many hours now looking for example code on Google, this forum and other forums, however most of the examples I have found are looking for two criteria within a column or specific criteria that is not suitable to my application (i.e. values <> certain numbers etc...).
View 8 Replies
View Related
Jan 23, 2010
I had a raw data sheet in which i need to prepare a statement just like the attached worksheet.
My requirement is to delete all those rows in the department column except the department which starts with "C" Just like "CNN" & "CNN-IN".
Rows with data containing the words starting with "CNN" should not be deleted .The rows can contain words with "CNN" or "CNN*"(here * denotes anything after the word CNN)
I had just formatted the whole worksheet for easy reference.Actually the raw data is extracted from other program which is very clumsy & irregular.
The department column might be in any column.
View 14 Replies
View Related
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
Mar 29, 2012
I need a macro that loops through all rows (With the exception of the first row) and looks for two conditions. If those two conditions are met, I'd like for it to delete the row.
The first condition is if Column O does not contain a certain phrase "VTX" VTX isn't the complete value of the column, it might just be contained within a few other notes in that column.
The second condition is if Col S equals "COMPLETE/FOLLOW-UP IMAGING".
So if these two conditions are met, Col O does not contain the word "VTX" and Col S equals "COMPLETE/FOLLOW-UP IMAGING", then that row should be deleted.
View 9 Replies
View Related
Jul 6, 2014
I am looking to make a cell with the Value =Today()-1. I then want the code to pick up the cell value and then delete any row that does not have that value.
So for Example it would only keep =Today()-1 Dates in the sheet and delete the rest.
Code:
Dim LR As Long, i As LongWith Sheets("Sheet1")
LR = .Range("Q" & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
If .Range("Q" & i).Value = "Y" Then .Rows(i).Delete
Next i
End With
View 9 Replies
View Related
Aug 21, 2007
I am trying to clear row with the following rules:
the last cell must not contain 0, if 0 delete entire row.
the first cell the the A row should be only three character long, if more delete entire row.
Now I managed to delete the 0 in the last cell and but cannot get the VBA to count the characters in the first row and if more than three, delete the entire row . I know to count the characters in a cell is done by Len(Rng.Value) , but getting the VBA right is alluding me .
the script is here,
Sub Del_rows_with_zero_in_column_of_activecell()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Const StartRow As Long = 1 'Row to Start looking at
Dim StopRow As Long
Dim Col As Long
View 9 Replies
View Related
Nov 10, 2008
I have a 20,000 row text file that I import. It has blank rows, page headers and footers, and many rows at the bottom that I do not want. I have been cleaning up the data manually but this takes a great deal of time and I have a need to perform this clean up on a more frequent basis.
I have tried recording a macro to do some of the deleting but I am running into an issue that I do not know how to over come. When I filtered the data based on "Blanks" on a specific column and then try to delete them in mass, Excel errors out stating that my request was too complex.
View 11 Replies
View Related