VBA To Delete 4 Row Range Based On One Cell Value
Oct 21, 2013
I have a spreadsheet broken out into about 30 4-row ranges, for example (A10:L13). All of the ranges use a using a vlookup argument:
=IFERROR(VLOOKUP($A10,Fund_Range,2,FALSE),"") in the second row.
Around 15 of the ranges will be populated based on varying data in the fund_range data table, the remainder will be blank. The first row of each range is a header row, I would like the macro to delete the range when there is no value in the second row (the blank ranges). Every attempt I have made starting with other code from the forum has come up empty. I think part of my problem is the vlookup formula existing in these otherwise "blank" rows.
View 2 Replies
ADVERTISEMENT
Jun 22, 2012
I would like to search my worksheet and whenever it finds the word "Description" in column "B" then it should select the range "B:E" for that row and delete the cells directly above it.
This is what I tried but nothing happens:
lr = ActiveSheet.UsedRange.Rows.Count
For Z = lr To 1 Step -1
If ("B:" & Z) = "Description" Then GoTo deleteit
GoTo xt
deleteit:
z1 = Z - 1
Range("B:" & z1, "E:" & z1).Delete
xt:
Next
End Sub
View 1 Replies
View Related
Dec 11, 2008
Let's say that I've got 125 sheets. The 1st "Reference", and the rest sheets names are "1" to "124". I need a macro to delete sheet based on cell range A1:A300. If the range contain 25 data so the number of sheet will be 26 (Reference and 1-25)
View 9 Replies
View Related
Aug 20, 2008
I have a "Temp Sheet" with a range in Column A:
ColumnA
Invoice #
S9700441
it will always be at least one but could be well over 100.
I have a code that creates a new tab for each invoice #.
But now I need a code to delete them.
Is there a way to delete worksheets based on a range?
View 10 Replies
View Related
Oct 14, 2008
Here is my
ThisWorkbook.sheets("sheet1").Range("M").Select
For Each cell In Selection
If cell.Value = ThisWorkbook.Sheets("Sheet2").Range("A").Value Then
cell.EntireRow.Delete
End If
Next cell
Range("a1").Select
End Sub
I want to remove all rows in sheet 1 that contain any value found in Sheet2 A I using XL 2003.
View 9 Replies
View Related
Jan 22, 2009
I have a table of data with which I need a macro to clear a range of data based on certain criteria. I have attached a file as an example. In this example the current period is 6. I therefore need to clear columns which have a period of 7 or higher.
Essentially, if the current period is x, then clear the range in the period columns if the period is greater than x.
View 6 Replies
View Related
Oct 21, 2013
I have a range (D5:BU5) that I will have various dates in each cell. At the end of the row is a percentage block. It has the formula count=(D5:BU5)/70 which gives me a percentage complete. The fun begins where some dates are based off annual, semi-annual, and quarterly. What I want to do is be able to delete cell values so they are not reflected in the final percentage. I know there is a marco that deletes the entire row but that is too much I just want a target cell.
View 3 Replies
View Related
Aug 14, 2009
I have a need to add or delete rows from a number of known sheet names using a table of variables on another sheet that tell me the start row of the sheet I need to go to and the number of rows I need to either add (ie copy rows and paste / insert these) or delete (delete rows).
There are multiple blocks of data I mey need to amend on each sheet and the values in my table of variables will change on each iteration (ie if I delete rows from the first block on a sheet, the start row for the 2nd block I need to amend will need to be updated in the table of variables before I can edit the 2nd block on that sheet).
I have been able to get the process to work for a single instance (ie one sheet and amendments to the first block of that sheet) but I can't figure out how to create the loop to elegantly move to the next set of variables and repeat the process for the 2nd, 3rd, 4th block etc on the first sheet and then move to the 2nd sheet to repeat the process etc.
Public Sub EditCurrentBlock()
Dim rowcount As Integer
Dim startrow As Integer
Dim endrow As Integer
Dim rowcountBal As Integer
'Dim selSheet As Worksheet (tried to use this to nominate the sheet variable but
' had problems so scrapped it)
'Reconfigure the GP Revenue block.................
View 2 Replies
View Related
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.
Code:
Public Sub Test()
Dim nRow As Long
Dim nStart As Long
[Code]....
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
Dec 9, 2006
I have the attached spreadsheet set up using a vlookup funtion in D1. I need the macro to be able to find the actual row this number resides in and delete that row whenever E1 is equal to Delete.
View 5 Replies
View Related
Jun 22, 2007
I currently have a spreadsheet with circa 50,000 lines with info regarding our websites at work. In every row, column "A" contains a unique reference number.There eill either be 1 row for this reference number, or there will be 2 rows. there will never be more than 2 rows for each reference. I wanted some code to say that if theres only one row, then delete it but if the if the cell underneath it is the same then its ok. I tried the following but it deletes the row anyway, supposing the cell under it is the same or not
Sub test()
Dim icell
icell = ActiveCell.Offset(1, 0).Value
Range("A1").Select
Do
If ActiveCell.Value = icell Then
ActiveCell.Offset(2, 0).Select
Else
ActiveCell.Rows.Delete
End If
Loop Until ActiveCell.Value = ""
End Sub
View 4 Replies
View Related
May 26, 2014
I need a code to delete all rows with "Complete" in Column D below Row 7.
View 2 Replies
View Related
Oct 22, 2012
I have this setup successfully for the deletion of columns and have modified the below to apply to rows, however, I am not seeing the results I expect (or actually anything).
Code:
Sub Analytic_RemoveNA()
'Remove NA
Dim j As Long
For j = 35 To 4 Step -1 'Rows 35 to 4
If Cells(9, j).Value = "NA" Then Rows(j).Delete
Next j
End Sub
I have a data set that spans from B4:I32. If column I has "NA" in any row within that dataset, I want to delete the row.
View 3 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
May 4, 2006
I need a way to check to see if the first four characters of cell A1 is = 2006. If it is, do not delete the row, else, delete the row. Have tried everything I can think of.
View 5 Replies
View Related
Nov 5, 2013
I would like to create a VBA code where it will delete the entire column if the cell value is equal to value in D2
For example:
Sub Delete_Columns()
Dim rng As Range, cell As Range, del As Range
Set rng = Intersect(Range("G2:S43"), ActiveSheet.UsedRange)
For Each cell In rng
If (cell.Value) = D2 _
Then
If del Is Nothing Then
Set del = cell
Else: Set del = Union(del, cell)
End If
End If
Next cell
On Error Resume Next
del.EntireColumn.Delete
End Sub
======
But I think this line is wrong but I am not sure how to fix it - If (cell.Value) = D2 _
View 5 Replies
View Related
Feb 15, 2014
I have the below given macro which does quite well at deleting the cell for a given value (Value = "_y-600_z-.jpg") in a given range. What I need for it to do is delete the cell contents if '_y-600_z-.jpg' is anywhere in the string. As an example, if the cell contains 'Handler_x-111251_y-600_z-.jpg' it will delete the cell contents.
[Code] ......
View 2 Replies
View Related
May 25, 2008
As I have been working I have highlighted cells and typed different names in the Name Box thus creating different lists. How do I delete the lists after they have been created?
View 2 Replies
View Related
Feb 22, 2014
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 Related
Dec 28, 2009
I have a spreadsheet with date and time values of the format
"dd/mm/yyyy hh:mm" in column A followed by some other data in cells of that row.
What I'd like to do is have a macro that will delete a complete row if the time value in column A lies between two times that I can specify in the macro (the dates are irrelvant)
View 8 Replies
View Related
Jun 7, 2012
I have two listboxes where I can move tickers from left to right. This is synced with a sheet, such that the tickers also are pasted there too.
But if I use the remove button, I can remove tickers from the listbox, but I cannet delete them from the sheet. If I understand right the listbox only refer to what row the selected is, not what the text is...
And then its a bit tricky. I have tried a code where it just add the list one more time, after the itmes has been removed. And that could work if it hadn't been for the second column which also has a text, this column is updated after every ticker has been moved from left to right.
What I would like to have is a function that would know what the text in the row that I delete, or remove.
This is what I have so far:
Code:
Private Sub cmdMoveToLeft_Click()
Dim i As Integer, j As Integer, k As Integer
Dim RowsStart As Integer
Dim LastRow As Long
Dim Rows As Integer
RowsStart = Me.ListBoxX.ListCount
[Code] .......
View 4 Replies
View Related
Dec 13, 2013
I have got a vacancy tracker spreadsheet and I need it to move an entire row from the 'Open' to the 'Closed' sheet based on the status in column K, i.e. 'Closed +', 'Closed -', and 'Closed + Achieve'. Once this has been done I want it to delete the entire row in the 'Open' sheet. At the moment it just cuts the entire row and then it is left blank and when I delete it manually the macro stops working completely.
Also I can only get it to move 'Closed +' and 'Closed -' and seem not to be able to add a command to move 'Closed + Achieve' rows.
This is what I have got so far:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Columns("K")) Is Nothing Then Exit Sub
Application.EnableEvents = False
If Target.Value = "Closed +" Then
[Code] .......
View 2 Replies
View Related
Feb 14, 2008
I am using conditional formatting to apply a light green color (index number 35).
Is there a macro that can delete the cell contents of the cells with this formatting in col K and L?
View 9 Replies
View Related
Jun 21, 2009
I have a spreadsheet (Sheet 1) listing current Work Orders with each work order occuping a seperate row; Column E lists the status of the work order, with the status being chosen from a drop down list.
I would like to have a macro that will copy the entire row and paste into (Sheet 2) when the status is changed to CLOSED, and clear the contents of the cells on Sheet 1.
The aim of this being of course to have all open work orders on sheet 1 and all closed orders on sheet 2.
View 9 Replies
View Related
Mar 9, 2007
I used this macro to find the duplicates in column B:
Sub KryDups()
ScreenUpdating = False
FirstItem = ActiveCell.Value
SecondItem = ActiveCell. Offset(1, 0).Value
Offsetcount = 1
Do While ActiveCell <> ""
If FirstItem = SecondItem Then
ActiveCell.Offset(Offsetcount, 0).Interior.Color = RGB(255, 0, 0)
Offsetcount = Offsetcount + 1
SecondItem = ActiveCell.Offset(Offsetcount, 0).Value
Else
ActiveCell.Offset(Offsetcount, 0).Select
FirstItem = ActiveCell.Value
SecondItem = ActiveCell.Offset(1, 0).Value
Offsetcount = 1
End If
Loop
ScreenUpdating = True
End Sub
The duplucate cells are now red in color. (RGB(255, 0, 0)). How do I now code VB to delete the rows in column B where the cell color is red? Here is some of the code that I tried:................
View 5 Replies
View Related
Aug 29, 2007
I have merged two workbooks into one. What I need to do at this point is to delete all rows that have a duplicate entry, basically anytime the cell content in one cell matches the cell content in the cell right below or above it, BOTH rows should be deleted. At this point, this is above my VBA skills so I'm asking for help in how to do this. The stripped version of the workbook is attached (only 100 rows) but in reality this is a huge workbook with almost 22,000 rows.
You will notice in the attached workbook, that cell contents for A2 and A3 match. For what I need to do, I need both rows (2 and 3) to be deleted. If you go down a bit, starting in row 89 all the contents in column A are unique so those need to remain.
View 3 Replies
View Related
Feb 6, 2008
I have a standard data import that populates data in columns A through DC. I am trying to delete those columns from BX through DA where the value in row 2 equals 0.
View 4 Replies
View Related
Feb 20, 2008
I am trying to create a macro that would be able to delete an entire row of data if a value in column A is equal to a range on a different sheet.
On Sheet “ISQ Raw Data”
If any value in column A (starting in row 2) is equal to a value on Sheet “Old Response IDs” Range A:A(all of column A)
Then Delete that entire row in Sheet “ISQ Raw Data”
View 9 Replies
View Related
Feb 22, 2007
I am not sure of the VBA code to delete enitre row if a cell is empty only within a range, then Ascend according to that Row's Values and show the
Rank No's only on what Rows that remain.
The end result example is in Sheet2
View 9 Replies
View Related
Mar 28, 2014
i am looking macro formula to delete row with 2 criteria :
- delete rows if yellow color background and based on adjacent cell (blank cell), otherwise keep rows when adjacent cell not blank
View 8 Replies
View Related