Delete Range With Conditions
Aug 10, 2009
I need a macro that will delete a range with some certain conditions. I have a set of dates in column B. The dates are in the format of 2009-01-31 09:15:00.
I need to search this column to find all the dates from the day before the computers date to the first day of the month before the previous days date. For example my computer date right now is August 10, 2009. So i need the macro to find all the dates from August 09, 2009 back to July 01, 2009 and select the entire rows that meet this criteria. Then I need to delete those rows.
Tomorrow when I run the macro it would choose all the data from July 01 - Aug 10, and this will go on each day until the end of december.
View 9 Replies
ADVERTISEMENT
Jul 21, 2007
I have data in column B and Column C. I am looking for a VBA script that will delete its corresponding row when both of these cells are empty. Example could be, if cells B9 and C9 are empty then delete row 9.
View 7 Replies
View Related
Apr 25, 2009
I would like to delete rows that are based on these conditions:
First ,Do a loop from row 2 to last available row
- Delete rows with same column(column B) that has the same value. However I want the last available row with the same ID to remain.
- Delete Rows with any values in found in other sheet column B. When the value taken from the first sheet(ABC) is compared to the column B in second sheet(DEF), if they are equal, the row will be deleted in the second sheet and the rows in first sheet will main.
The comparsion of ID are compared between sheet ABC and sheet DEF
(the Highlighted are those rows to be deleted based on those conditions)
The final outcome are shown on col H I J for sheet ABC and col I J K for sheet DEF.
ABC
ABCDEFGHIJ1QtyProduct
QtyProduct
2100111Case 1
100222Case 33100222Case 3
50333Case 1450333Case 1
57444Case 3557444Case 3
150666Case 26200555Case 1
100111Case 17150666Case 2
100888Case 38100111Case 1
231999Case 19100888Case 3
200555Case 110231999Case 1
100112Case 411200555Case 1
100113Case 112100112Case 4
100114Case 2 13100113Case 1
100115Case 114100114Case 2
View 9 Replies
View Related
Jul 20, 2009
I need help with the following conditions. I have attached a sample file with desired results.
Conditions required to delete row:
1Delete Row when cell E is blank (example: Row 6 will be deleted as E6 is blank)
2First character in column 'C' is an alphabet (for example: Row 5 will be deleted as the first character in the cell is an alphabet
3First character in column 'B' is an alphabet (for example: Row 29 will be deleted as the first character in the cell is an alphabet
Special Notes : All characters in column 'B' are not in number format (ex: 555-9999 is general)
There are more than 1500 rows of data that need to be sorted with the above conditions.
View 9 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 1, 2012
I have a sheet caled "Data", with thousands of rows.
I want to delte any rows that have duplicate rows only if the following data is in the same row but if in column A, coloumn C and column H have the same data
A B C D E F H I
w 1 1 3 4 5 6 7
e 1 1 1 3 4 5 8
w 2 1 5 2 5 6 7
The last row would need to be deleted as dupilcates are A C and H
The data is not sorted.
View 3 Replies
View Related
Aug 1, 2008
I need to eliminate the passing jobs, leaving the failing ones so I can do coaching sessions with the guys that are missing the mark.
Conventions of the report:
Each job has a 20 digit job # and is allocated 12 rows worth of information fields unless customer has more than 1 cable outlet with a modem, then the rows increase by 4 for each additional modem
Tech name is repeated after every 12 rows even if within the same job #
On passing jobs, column I will only contain “Yes” (there are blank cells in column I, as not every parameter is checked on every job), failing jobs will contain “No” in column I
Items I need to accomplish:
· Increase column C width to 22 and column E to 25
· Format column C to number, 0 decimal places (to avoid scientific notation)
· Move tech name to beginning of each job # and eliminate repeated names
· Delete all rows plus tech name on passing jobs
· Change cell color to red in rows (columns A-I) that contain “No” in column I
I have highlighted each different job # in different color
John Smith10002934422610200000Outlet 2D - Up Stream SNR274029.4Yes10002934422610200000Outlet 2D - Up Stream Tx365546Yes10002934422610200000Outlet 2D - Down Stream .............................
View 10 Replies
View Related
Jul 16, 2013
I'm trying to remove cells that contain certain suffixs. Here is the code I'm trying to use:
Code:
For i = 7 To 2000
If Cells(i, 7) = "IV," Or Cells(i, 7) = "Jr," Or Cells(i, 7) = "III,"
Then Cells(i, 7).DELETE Shift:=xlToLeftEnd IfNext i
but it does absolutely nothing. I've used this for similar macros in the past and it worked just fine.
View 4 Replies
View Related
Aug 26, 2013
I am trying to create a macro to accomplish the following task. Delete if the value belongs to queue "ab cd ef" and is also a part of category "xxx xxx".
I wrote the following code, but it seems it is doing some mistake:
Code:
LastRow = Range("Z2").End(xlDown).Row
For i = 2 To LastRow
tempQueue = Range("C" & i).Value
tempRange = Range("Z" & i).Value
If (tempQueue = "ab cd ef" And tempRange = "0 - 1 day") Then
Range("C" & i).EntireRow.Delete
[Code] ........
The above code works fine but it deletes only 120 rows out of 200 or sometimes 150 out of 200. Can't get it to work all 200 rows.
View 4 Replies
View Related
Mar 2, 2006
I 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).
View 9 Replies
View Related
Jan 14, 2008
Each task in my spreadsheet has multiple jobs assigned to it. Frequently users will work two jobs for the same task simultaneously and log the time together.
Unfortunately when I go to try to sum up how much time was spent on each task, this causes it to appear as if the task took twice (or even twenty+) times as long as it truly did.
I want to be able to figure out the time spent on each task for each user. In order to do this, I need to get rid of rows where the task id and the user id are both duplicated in another row.
Ex: ...
View 4 Replies
View Related
Jun 5, 2014
Maybe this has been taken care of in another thread, but still:
ROW ID NUM OCC K OCC I
1 222222 0 0
2 222222 0 0
3
4 333333 0 0
5 333333 0 0
6 333333 0 0
7
8 444455 1 1
9 444455 1 1
I have a situation like above, but what I want to do is:
=FOR(ROW1:ROW9, IF COUNT ROWS(ID_NUM)>= 2,
(create name for set?)
AND
IF OCC_K AND OR OCC_I VALUES >= 0,
THEN DELETE ROWS(within set) >=2
Or more simply:
If there are rows with multiple Accident ID numbers, name that set,
and if OCC_K and/or OCC_K values are BOTH >= 0,
then delete all duplicate rows?
Yes I figure there needs to be some way to distinguish Row 1 from Row 2, (flagging one of the two?) so that ROW 2 can be identified, and similarly with Row 4 from Row 5 from Row 6, but the general flow of commands is what I'm trying to get at.
Is it also possible to use AND and OR in the same line? Or BOTH?
(I have other variations on this that I also like to ask about, such as multiple rows within a set that meet certain conditions that are identified in a different field, but for now this is a simpler version.)
I would like to think I'm not going to need a macro, and that I can do this in a Formula.
View 10 Replies
View Related
Aug 17, 2009
I have random "X"s in a column of cells in a range called "Won". I wish to count these if the adjacent cell in another range alled "Valu" is greater than a value determined in the cell E3. The result to be entered in Cell G4. Can use Excel formulas or VBA.
View 4 Replies
View Related
May 15, 2012
How to get the MAX of a range if 3 conditions are met.
1 after this date
2 before this date
3 Column G is equal to A2
Ranges are on sheet1
Date reference is on sheet2
range to sum is on sheet1
V14.
something like
MAX sheet1!H:H
IF sheet1!$G:$G equals $A2
AND sheet1!$P:$P,">="&EOMONTH($B2,-1)+1
AND sheet1!$P:$P,"
View 7 Replies
View Related
Aug 16, 2009
I have a named range “Value” and wish to count all the values over the value set in cell E3. The result to be entered in cell F4.
I have a second named range “Won”, adjacent to “Value”, and wish to count these values if the adjacent cell in the “Value” range has been counted. The result to be entered in cell G4.
View 2 Replies
View Related
May 15, 2012
How to get the sum of a range if 3 conditions are met.
1 after this date
2 before this date
3 Column G is "OTH"
Ranges are on sheet1
Date reference is on sheet2
range to sum is on sheet1
V14.
Present formula is:
=SUMIF('sheet1'!$P:$P,">="&EOMONTH($A2, -1)+1,'sheet1'!$H:$H)
-SUMIF('sheet1'!$P:$P,">"&EOMONTH($A2,0),'sheet1'!$H:$H)
This works fine but lacks the 3rd condition 'sheet1'!$G:$G ="OTH"
Advise given was to go on SUMPRODUCT but unless with (OFFSET(INDIRECT, SUMPRODUCT wouldn't work on multiple sheets. And this is for version 14...
View 5 Replies
View Related
Dec 6, 2007
I have written a function below which is supposed to give average of selected range and will ignore #N/A, if any. Naturally, i use array formula:
Function m_avg(mRange As Range)
m_avg.FormulaArray = "=AVERAGE(IF(ISNUMBER(mRange),mRange))"
End Function
the above doesnt work and gives me #VALUE!.
View 3 Replies
View Related
Jul 27, 2012
I have a spreadsheet which has data in rows. I need to sum the first 5 values from the left of the range which are greater than zero. BUT if there are less than 5 non zero values present I want to sum from the right of the range.
First condition:
1 2 3 4 5 6 7 8 9 10
The function would return: 1+2+3+4+5 = 15
Second condition:
0 0 0 4 5 6 7 8 9 10
Function would return: 4 + 5 + 6 + 7 + 8 = 30
Third condition:
0 0 0 0 0 0 0 8 9 10
The function would return: 10 + 9 + 8 = 27
I have had success with:
=B4+SUM(SMALL(IF(I4:O4<>0,I4:O4),ROW(1:5)))
(using ctrl shift enter)
BUT it crashes when faced with the third condition.
I would also like to avoid ctrl-shift-enter functions if I can as I don't have much success copying them around the spreadsheet.
View 3 Replies
View Related
May 14, 2014
1) Input data are static and helper columns can be added if needed.
2) Filter will be dynamic range (in attachement is the filter static), and the count of years can be changed on users request. So there could be only 2011, but also 2011+2012, 2012+2013+2014 etc.
3) In col 'J', the is what I know to do, but I do not want to use SUMIF+SUMIF+SUMIF... for each year (the count of years will change througt time as mentioned above).
View 3 Replies
View Related
Mar 15, 2014
I am trying to pick certain data from a table and sum it in order to produce a formatted report.
The data has many different items of which I want to pick certain ones to sum on one line
See attached and some of the formula's that I have used, but aren't quite what I'm after
The formula I want to use is .... VLOOKUP(E5:G5,A14:C23,3,) ......
But it wont reference a range (E5:G5) !!! and I also want the formula to ignore blanks (as blanks in the data file are actual totals).
View 2 Replies
View Related
Jul 31, 2008
My data is as follows
MonthMilesAmountLocation
June 8£3.20 Loc1
June 8£3.20 Loc1
June 8£3.20 Loc2
July 8£3.20 Loc2
July 8£3.20 Loc1
July 38£15.20Loc1
July 4£1.60 Loc2
Aug 38£15.20Loc2
Aug 4£1.60 Loc1
Aug 8£3.20 Loc1
Here is what I want to do
- Avoide filtering and manually calculating data for the total expense in the month
I want to SUM all the (3)AMOUNT in the (1)MONTH of JUNE for
(4)LOCATION LOC1
I know its too much to ask for but can you suggest if i can combine SUMIF or SUM(IF) or any other formulas ???
View 10 Replies
View Related
Dec 17, 2012
I'm trying to code a clean up of some data ranges ready for priting / reporting. I need to move filtered data from the source sheet, to a new one.
The issue is, that I need to apply some logic to the rows I filter out, not something I can do with autofilter...
- Only copy rows including and BETWEEN the first and last rows where total count in col 8 is > 0
So in example1, I'd want to copy out rows P6 - 1A
BUT
- Always copy at least 5 rows when there is one value > 0 in col 8
So in example2, I'd want to copy out rows P5 - 1C, ideally...
Total
Boys
Girls
Total
[Code]....
View 3 Replies
View Related
Nov 13, 2006
I'm creating a summary sheet that adds up all the data on sheets between start and finish where A2-A25 is SU and B2-B25 is 004*04. Background info: SU stands for SetUp, and 004*04 is a workcenter number (its not 004 times 04) I'm trying to calculate the total number of Setups for each workcenter.
=SUM((start:finish!A2:A25="SU")*(start:finish!B2:B25="004*04"))
gives me a #NAME? error.
Example Data on each spreadsheet:
A B
SU 004*02
SU 004*04
SU 004*04
SU 004*02
SU 004*04
View 9 Replies
View Related
Dec 7, 2006
In the screen shot I'm trying to find the row number where a particular price of an order has been reached. In this case, for the first order, my execution price is 1.8859, my stop loss is 1.8834 and take profit is 1.8884. I need to look and the future prices to determine which event had occured first (either the take profit or the stop loss). I though by using row numbers I would compare and which ever is smallest would mean that it occured first - the profit/loss is then calculated.
The other caveat is that an exact match may not always be available - for example, the second trade is stoped out because the highest price for the 12:35 timeframe exceeds the value I'm looking for. Still it would have triggered a stop loss.
******** ******************** ************************************************************************>Microsoft Excel - Misc.xls___Running: xl2002 XP : OS = Windows XP (F)ile (E)dit (V)iew (I)nsert (O)ptions (T)ools (D)ata (W)indow (H)elp (A)boutH6I6J6M6H7I7J7M7H8I8J8M8I9J9M9I10J10M10I11J11M11I12J12M12=
ABCDEFGHIJKLM3DateTimeOpenHighLow*Order*PlacedOrder*PriceStop*LossTake*ProfitStop*Loss*Row*#Take*Profit*Row*#Profit/Loss42006.11.1512:001.88651.88661.8863*N***these*are*the*cells*that*need*the*formula*52006.11.1512:051.88651.88661.8856*N******62006.11.1512:101.88591.88591.8857*Buy1.88591.88341.88841080.002572006.11.1512:151.88581.88591.8853*N*...............
View 10 Replies
View Related
Sep 5, 2006
I have this macro to copy a range to another worksheet:
Sub transpose_UPCID() ' Hace el copy y paste transposed en BAUCS de los numeros de UPC"s y
' las cajas ATR
Dim rng1 As Range
Dim rng2 As Range
Set rng1 = Sheets("Sales-Inventory").Range("UPC", Range("MK_ID").End(xlDown))
Set rng2 = Sheets("Sales-Inventory").Range("Figure", Range("Figure").End(xlDown))
rng1.Copy
Sheets("BAUCS").Range("C11").PasteSpecial Paste:=xlValues, _
Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True
rng2.Copy
Sheets("BAUCS").Range("C37").PasteSpecial Paste:=xlValues, _
Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True
Application.CutCopyMode = True
End Sub
The only problem is that this code copies all the items and I need this code to look into Column A in the Sales-Inventory worksheet. There I have a data validation with a total of six options. I also have six differents worksheets where I need to copy the values based on that data validation. To give you and example, all items containing XX in column A copy to XX worksheet. Something like that.
View 9 Replies
View Related
May 16, 2007
Please take a look at this sample spreadsheet.
[url]
I am trying to find out how to write a formula that will sum the values in one column if the value in a corresponding column is within a range. For example, if the item number in the first column is greater than 2 and less than 7, the sum would be 179. I believe this would be some type of SUMIF but I cannot write it.
View 3 Replies
View Related
Dec 7, 2007
I have a VERY complex custom data validation formula that is getting crazy. I thought it might be easier to use a user defined VBA function to handle it, but was unsuccessful.
I was able to write a VBA User Defined Function & use it within my spreadsheet to derive the value of another cell, as follows: =IF(OR(ISBLANK(B12),myValidation(B12)),"OK","NG")
I tried using it as a Custom Data Validation on the cell itself (=myValidation(B12)), and I get an error: "a named range you specified cannot be found".
Can the function be used in this way or could someone suggest another way of handling this?
View 6 Replies
View Related
Mar 15, 2013
Assume this Data in a spreadsheet
I want to count blank "PI" based on "Product name" & "Product date" occurence together
So I created intermediate field "IS Blank", and I dunno what formula can give me the below results
My obective to get this result
CountBlank for PI = 3
--------------------------------------------------------------------------------
Product Name..... Product Date.... PI...... IsBlank "PI" [Desired Formula output]
xxx .......................ddd ...............Blank.................. 1
xxx .......................ddd ...............Blank.................. 0 (counted above for same xxx&ddd)
xxx .......................ddd222 ..........Blank.................. 1 (PD changed to ddd222)
yyy ......................ttt............... Blank....................1 (another product,yyy)
yyy .....................ttt ...............Blank......................0 (same product and date, so not counting again)
View 9 Replies
View Related
Jan 29, 2009
I want to auto fill certain columns in sheet A from sheet B & sheet C based on conditions
For Eg:
Sheet A:
Position#
Position Name
Personnel Name
Personnel No.
AB1
Manager
AB2
I want to auto fill in Sheet A for the columns:
Personnel Name
Personnel No.
Conditions:
If the employee is active in Sheet B then fill in Sheet A to the related position No.
Else
If the employee is mapped to org. (Yes) in Sheet C then fill in Sheet A to the related position No.
Else
Vacancy
i have written the below formula but not working properly:
=IF(VLOOKUP(SheetA!A4,Direct!A$2:K$16,5,FALSE)="Active",VLOOKUP(SheetA!A4,Direct!A$2:K$16,3,FALSE),IF(VLOOKUP(SheetA!A2,Contractors!A$2:K$15,5,FALSE)="Yes",VLOOKUP(SheetA!A2,Contractors!A$2:K$15,3,FALSE),"Vacancy"))
View 9 Replies
View Related
May 30, 2008
I have a rolling calendar worksheet that I need to create a formula to auto populate the sum of 8 weeks out, 4 and 8 weeks back based on any work week date I may plug in. So on the "summary page" based on a work week date, I need 8 weeks out, 4 and 8 weeks back projections to be auto summed for 10 different part numbers. The "13 week rolling" page will continue to be updated so that everyweek another week is added and the last week will fall off. (this part can be done manually if no function can delete the oldest column) When the weeks are added it must include the workweek in question. i.e. ww25 = (8weeks out) ww25:ww32 / (4weeks back) ww25:ww22 / (8weeks back) ww25:ww18. see example workbook attached.
This has been driving me nuts for a few weeks now.
View 2 Replies
View Related