DELETE Row Based On Content Of Column
Jan 8, 2008Need 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.
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.
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 ?
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"))
'Worksheets("Sheet1").Range("A5").End(xlDown).Delete
Now when its pasted it has cells with "Nil" in it. I need to delete them, or just not copy them over.
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"
EX:
05S0128
06S0112
05S2298
S25852
S36963
SA36185
I would only like to keep the last 3 lines.
Sum A1:A100 only for corresponding B1:B100 containing "paid". translate that to a formula? I don't know conceptually how to approach it.
View 1 Replies View RelatedI have a 3 column table with 20 rows. The first two columns contain travel
expense data. The cells in the third column are blank exept for whichever
cell I enter an "x" in. Please let me what formula or worksheet function do
I use to calculate the travel expenses based on the data in the first two
columns that correspond to the row of the cell with an "x" in the third
column?
I am trying to create a formula that will look at an entire row of data and if a certain cell in that row meets a particular criteria, it will pull data from another cell in that same column. I am not sure how to get this started.
View 9 Replies View RelatedCurrently have a sheet with column A/B. Column A has any of the following letters to represent Wins, Losses, Ties, Overtime Loss, Shootout Loss - W, L, T, OTL, SOL. Column B has team point totals after each result. So after the win in row one, the team has 2 points. After the losses in rows 2 and 3, the team still has 2 points. After win in row 4 the team has 4 points. After win in row 5 the team has 6 points. After tie in row 6 team has 7 points.
W
2
L
2
L
2
W
4
W
6
T
7
What is the best formula or is there a formula to easily calculate running total based on content from column A this for over 1700 rows?
Formula/macro/etc that would enable me to have content of a cell changed based on the content of another cell in the same row.
Example: cell in column D says "PSA" - so I would need the cell in column H for that same row to read "Radio"
I would need an entire sheet scanned to review for these occurrences and make the appropriate changes. I also would need the formula to be inclusive enough to scan for variations in column D cell content (PSA 1, PSA 2, etc).
For a table like the one below produced for the sake of example (actual is much much bigger) I want to make it list rows that are true for a certain column for a certain variable in the matrix. So for say water terrain, which types of activity can I do i.e. swimming. Or for Offroad the activites which I can't do i.e. Run and Swim.
ActivityWaterRoadOffroad
Jog nym
Run nyn
Walk nyy
Swim ynn
y=yes
n=no
m=maybe
I have a spreadsheet with several columns (all column names are in row 1).
I have 2 of column names. Note that their actual column# might change so the macro would have to look for the column name and NOT the column position ...
I am trying to find something that will let me look at a Log Book Page (a Worksheet). I need it to look through Cells E4 trough E15 I want it to look for the 1st entry of 3 different materials.
3/4" Plywood
1/4" Plywood
3/4" Particle
These names are in a drop down menu from a different sheet in the same work book
Sheet Name link '.'!
'.'!A2 3/4" Plywood
'.'!A3 1/4" Plywood
'.'!A4 3/4" Particle..............
I have a column containing mixed text and I want to remove everything from the column except instances of certain colors; black, red, blue etc. Is there a formula which would do this or can it be done with Search/Replace?
View 9 Replies View RelatedI need a macro that will search though Column AD and delete the cell contents if the cell contains "0" (zero). Edit: I'm sorry I just figured this out using the following
Dim lastrow, j As Integer
lastrow = Cells(Rows.Count, "ad").End(xlUp).Row
'I presume the last row C is not blank
For j = lastrow To 1 Step -1
'MsgBox j
If Cells(j, "ad") = 0 Or Cells(j, "ad") = "0" Then
Range(Cells(j, "ad"), Cells(j, "ad")).Clear
End If
Next
I have a long list that has all the services from our stores. I´m using the formula below to count how many services does each store have that are over 20 days old.
=SUMPRODUCT((G!$A$2:$A$6000=$B4)*(NOT(G!$I$2:$I$6000="Valmis/Odottaa nouto"))*(NOT(G!$I$2:$I$6000="Valmis, toimitettu"))*(NOT(G!$I$2:$I$6000="Finished/WaitingDeli"))*(Päivämääärät!$C$1-G!$C$2:$C$6000>Päivämääärät!$I$3))
Now i´m wondering is it possible to make a macro that would delete all the cells in the range that do not match the criteria of my formula?
With one exception in sheet G cell A2--> has the number of the store. There are over 40 stores so each store has a number 10, 20, 30, etc...
This is the part of the formula that determines witch store it is counting
(G!$A$2:$A$6000=$B4) B4=10 in this case and B5 would be 20 and so on... By modifying that one part i can count old services for all of our stores.
Now I want the macro to delete all services from the list that are not over 20 days old and belong to the store 10 (B4). If it would delete everything that dont match that formulas criteria i could not get a list of old services for our other stores.
What i´m trying to accomplish is get a list of the services that are over 20 days old. I´m now picking them from the list by hand and that takes a really long time. Because of the number of the stores and the size of the range.
I got some data like this
CTM
KKB
ACD
TEEE.PK
ACFFE
OO.OB
What i want to do is to delete everything after the dot. And the dot itself
I have a data of 10 rows and 6 columns, if i delete the data in column 1, I want the entire row 1 to get deleted and this I want using IF Statement.
View 2 Replies View Relatedi have code like this to copy certain word in cell and place it at new sheet:
VB:
Sub Foo()Dim i As Long, iMatches As Long
Dim aTokens() As String: aTokens = Split("Accommodation", ",")
For Each cell In Sheets("Sheet1").Range("C:C")
[Code].....
the problem is the cell source is not deleted. what line should i change in code above to move the result to new sheet and delete row source
i have data from D2:D10000
I Used data of first five rows e.g ("d2:d6") if in range ("d2:d6") any cell is blank then delete the all contents of the rows
e.g
d2 have data
d3 have data
d4, d5, d6 have no data then the contents of range ("d4:d6") should delete
I recorded a macro:
Code:
Sub Makro4()
Range("A4:C15").Select
Selection.ClearContents
[Code] ......
This code is working home on my MacBook, but I wonder if you have any suggestions for improvement? I will assign this macro to a button.
I am having some trouble writing a macro to delete cell content. I know which cells I want to clear, but I can't seem to get the macro to do it.
I also want to have something in the macro that inserts data into the lines that I am trying to clear. I want cell A67 to say "Payment" and cell A71 to say "Total."This is the code I am using:
Sub DeleteCell()
Dim i As Integer
For i = 67 To 71
If Range("A" & i).Value = "--" Then
Range("A" & i).Delete
Next i
End Sub
I need a VBA that i will attach to a button that will delete spisific data in the cell.
Eg... delete all the cell CONTENT in column A1:A65536 with the word "NONE" in them, it must only delete the word not the cell.
I am using VBA
I have an input box pop up to ask the user for a base item number. The way the excel sheets part numbers work for example is TM-T88VP-GRY, the last part 'GRY' changing based on the variation of the item that someone ordered. So, the base item number would be TM-T88VP, and what I want to do is search through a set column (Column G) and delete any row that contains that base item number.
What i really need it to do is if each row in column H = "Cleared" then to only clear columns A, C to H. Theres a formula in B that needs to be left... any ideas?
Also i need this to work on all atbs as the commandbutton will on a master tab
VB:
Private Sub CommandButton1_Click()
With ActiveSheet
.AutoFilterMode = False
[Code]....
I have this sheet(sheet2) with some data , I have 2 macro, my problems at this time is that I am looking for macro that delete only the blank rows that under the rows with {SELECT ....} and the under the blank rows with {CELL-ENTER......} and all the rest blank leave in place , I am also looking for option to integrate the new macro with the existing one and come up with one macro that I can refer to click button , in case that it is unfeasible , it's ok with me , I just will call the other macro at the from the first macro that I have.
View 4 Replies View RelatedSimple code that can delete entire row if certain criteria is met in a single cell
Example
I have a bank statement where under a first column (DATA TYPE), the cell could contain either "DATA" or "TOTAL"
How can I delete the rows contain the word "TOTAL" assuming the column is already sorted.
I have a set of data I'm trying to clean up. I'd like some code that would look at column A, and if a duplicate is found in A, delete the duplicates entire row. Column A contains a unique identifier code.
View 9 Replies View RelatedI have a report in which I need to delete the entire row for each cell in Column A that has the name "Defacto" in a certain location in that cell. I am trying to use VBA code in conjuction with the "MID" function [i.e., Mid(Cell.Value, 8, 7) = "Defacto"]. This is the code I came up with (but, obviously, it doesn't work):
Sub DeleteRowOnCondition()
Range("A2").Select
Range(ActiveCell, ActiveCell.End(xlDown)).Select
For Each Cell In Selection
If Mid(Cell.Value, 8 , 7) = "Defacto" Then Rows.Delete
Next Cell
End Sub
As well, there is another worksheet in the same report in which I need to delete all the rows that do NOT meet that condition (while retaining the ones that do).
I would like to Use my Excel VBA program to search each row in a csv document for a name (located in a cell ) if the name exists then I would like to delete the entire row.
Whenever I try to do the above in excel, even when I save in csv format the file formating or something gets changed and the file which has to be procesed through another program then process incorectly.
Is there a way to do what I need while retaining the formating which must obviously be changed when the file is opened in excel?
The attached picture shows part of an excel file. It contains about 50.000 rows which I want to run a pivot on. The problem is though that the file contains some rows which stop my pivot from running correctly. These data which I mention are in rows 4, 7, 22-25. Seeing as deleting them manually would take me hours and hours I was wondering if there would be a macro which I can run which delete rows automatically. I think it should filter on the following: whenever there is not a numeric value in column A, the entire row should be deleted.
View 6 Replies View Related