Delete Sheet Based On Cell Range

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


ADVERTISEMENT

Delete A Range Based On Cell Value?

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

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 View Related

Copy Rows To Sheet Based On Cell Value In Range

Aug 16, 2007

a macro button on my excel sheet that should do the following.

i have a range (Ex: E3:E46) which is being continuously filled, i need to transfer the information to another sheet depending on column "E", (Ex: if "E3" = "A" paste row to sheet2 if = "B" paste row to sheet3) and so on each row could have another string in column "E".

after the paste is done it should clear the range making place for new entries, that should also be copied finding the next empty cell (it shouldn't delete the old entries)

View 9 Replies View Related

Dynamically Fill Range Of Columns Based On Value Of Cell In Another Sheet

Feb 24, 2014

I wanted to enter value in sheet1 on A1. Columns in sheet2 from B1 until the value entered in sheet1.A1 should be automatically filled.

E.g.

Sheet1.A1=5, then Sheet2.B1=1, Sheet2.B2=2, Sheet2.B3=3, Sheet2.B4=4, Sheet2.B5=5.

if Sheet1.A1=3, then Sheet2.B1=1, Sheet2.B2=2, Sheet2.B3=3.

if Sheet1.A1=7, then Sheet2.B1=1, Sheet2.B2=2, Sheet2.B3=3, Sheet2.B4=4, Sheet2.B5=5, Sheet2.B5=6, Sheet2.B5=7

etc.

View 2 Replies View Related

Delete Certain Columns Based On Sheet Name

Jun 15, 2013

I have a workbook with sheet name Par1, Par2, Par3, Par4, Par5 and Par6. On each sheet I have the following data.

Name
EmpID
Process
Par1
Par2
Par3
Par4
Par5
Par6
Par7
Par8

A
30380
YRC
10.04
16.11
21.88
463.85
7.00
486.10
229.00
21.88

[Code] ......

for sheet name Par1 , I want to keep first three columns and column name with Par1...same for all the sheets. But there are some exception.

For sheet name Par4 , I want to keep first three columns and column name Par4, and Par7 .

For sheet name Par5 , I want to keep first three columns and column name Par5, and Par7 .

For sheet name Par6 , I want to keep first three columns and column name Par6, and Par8 .

I am using the below code for the same. But this is not working.

Code:

mybook.Activate
For Each sht In mybook.Sheets
sht.Activate
For j = sht.Range("A1").CurrentRegion.Columns.Count To 4 Step -1
If sht.Name "Par4" Or "Par5" Or "Par6" Then
If Cells(1, j) sht.Name Then

[Code] ......

View 3 Replies View Related

Delete Sheet If Range Is Empty

Feb 26, 2012

how to write a module that will if check if

if cell A5 has text in it,

check range (b5:t5) for any empty cells or any cells with the word "sp" in it,if there are any empty cell or cells with "sp" delete this sheet.

then check

if cell A8 has text in it,

check range (b8:t8) for any empty cells or any cells with the word "sp" in it,

if there are any empty cell or cells with "sp" delete this sheet.

View 3 Replies View Related

Delete Rows Based On Criteria On Another Sheet?

Nov 21, 2012

few macros/vba that delete rows based on criteria in a cell.

I'm after something a little different. I have a workbook with sheets called Raw Data1, Raw Data2,Raw Data3, Raw Data4 and Raw Data5 and Menu.

There is a column of data in each of the sheets which has a column header of 'Location', however the column where this is located will vary from sheet to sheet. For example in Raw Data1, this is column 'J' and on Raw Data2 it will be column 'M', ( I'm not at work and can't remember the specific column positions for all sheets re: 'Location').

Is it possible to have on the 'Menu' sheet, say in cell B5 a value of 'Locationa' and have rows be deleted in each of the Raw Data that do not match the value in B5?

View 4 Replies View Related

Find Matching Value In Range On Different Sheet And Delete?

Jan 28, 2014

I am an inventory specialist for a dish network company and as such I track inventory in and out of technicians vans, both serialized and not. I've done a great deal of work updating a broken excel sheet they use so that it functions again but I didn't build it. I've learned a lot but I'm only self taught with Excel and had never even heard of VBA code until I dived into this project. It's a huge puzzle and is now my "baby".

Anyway, basically I have one sheet that has a list of all the items I need to keep track of. One section of this Sheet1 I've designed to have cells with dependent drop down lists that are Named Ranges on Sheet2. The tech can choose item A B or C in the first dropdown box and then the next cell shows only the serial numbers from the named range on Sheet2 of A B or C. (Was that english?)

Since the receiver comes out of the techs van once its used I want to figure out a way to delete the serial number that the tech has chosen without deleting the row or cell, just the value in it so that it can then have another serial number typed in. How can I do that?

Also, since I'm here, my 2nd drop down list seems to always start scrolled down and I have to scroll up to see my serial numbers. Why is that? The receiver list starts at the top but the dependent one doesn't...

View 2 Replies View Related

Delete Sheets Where Sheet Name Not In Range Of Cells?

Mar 13, 2014

I am looking for some code to scan my sheet names and delete all the sheets that don't have names corresponding to the values within a cell range contained on another sheet in the workbook. For example, if any sheet name, excluding a few reserved sheets, doesn't equal one of the values contained in cells A2:A23 on sheet "XYZ" then delete it.

The best solution I could come up with using my experience was to loop through each sheet and compare the name to each cell in the named range, but if it's possible to somehow declare the named range so that each sheet only has to compare to it that would be ideal;

View 10 Replies View Related

Find Matching Value In A Range On Different Sheet And Delete

Jan 18, 2014

I am an inventory specialist for a dish network company and as such I track inventory in and out of technicians vans, both serialized and not. I've done a great deal of work updating a broken excel sheet they use so that it functions again but I didn't build it. I've learned a lot but I'm only self taught with Excel and had never even heard of VBA code until I dived into this project.

Anyway, basically I have one sheet that has a list of all the items I need to keep track of. One section of this Sheet1 I've designed to have cells with dependent drop down lists that are Named Ranges on Sheet2. The tech can choose item A B or C in the first dropdown box and then the next cell shows only the serial numbers from the named range on Sheet2 of A B or C. (Was that english?)

Since the receiver comes out of the techs van once its used I want to figure out a way to delete the serial number that the tech has chosen without deleting the row or cell, just the value in it so that it can then have another serial number typed in. How can I do that?

Also, since I'm here, my 2nd drop down list seems to always start scrolled down and I have to scroll up to see my serial numbers. Why is that? The receiver list starts at the top but the dependent one doesn't...

View 4 Replies View Related

Delete Range Names That Refer To Sheet

Dec 19, 2006

I am looking for a way to delete all the range names in a worksheet, not the whole workbook. I have found several procedures that will delete all the names in an activeworkbook. For some reason it takes too long to run. Does anyone know how to handle a single sheet in VBA?

View 6 Replies View Related

How To Delete Worksheets ( Based On A Name In Range)

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

Delete Row Based On Range Selection

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

Macro To Delete A Range Based On Certain Criteria

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

How To Delete Cells In A Range Based On Date

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

Unhide Sheet Based On Named Range In That Sheet

May 6, 2012

Is there any way (in vba code) to unhide the sheet of a given named range?

If would come before the following line of code whee CurReference is already defined

Application.Goto Reference:=CurReference

View 1 Replies View Related

Add Or Delete Rows From Multiple Sheets Based Table Range

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

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.

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

Delete Sheet Named In Cell

Aug 26, 2008

I need a button to delete a sheet and the sheet to be deleted needs to come from a cell. For example: Active sheet is sheet 1. User selects the name "sheet 5" within cell B10 via data validation from cells E1:E9. Then the user clicks the button and that sheet is deleted. The data validation is a list of every sheet name except sheet 1. If possible, there is a sheet labeled "0" and I cant have that sheet deleted or it will screw up all my formulas if that's too difficult I can work with the data validation to keep a zero from showing up.

View 3 Replies View Related

Delete Row Based On Cell Value

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

Delete Row Based On Cell Below

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

Delete All But 1 Worksheet, Add New Sheet & Name As Cell Text

Jun 7, 2007

I need to cycle and extract row data from the A, B and D columns and copy it into another worksheet while maintaining the copied data structure. Right now I am manually selecting the data....

View 9 Replies View Related

Returning Cell Value From Sheet 1 Based On Cell Reference From Sheet 2

Oct 29, 2013

In Sheet2 I have a list of cell addresses showing values such as D5, D32, D59, D221, D869 stored in cells AB7:AB16. In Sheet1 the "D" column holds dates. I want to return the corresponding date for each D# cell into Sheet2 in column AC7:AC16. I'm unaware of the proper syntax for this. I though it would look something like:

='Sheet1'!('Sheet2'!(AB7))

however that doesn't work.

View 2 Replies View Related

Delete Row Based On Cell Text?

May 26, 2014

I need a code to delete all rows with "Complete" in Column D below Row 7.

View 2 Replies View Related

Delete Row Based On Cell Value - Loop

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

Delete Rows Based On Cell Value?

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

Delete Row Based On First 4 Characters Of Cell

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

Copy Rows From Selected Sheet To New Sheet Based On Cell Value

Mar 27, 2008

i have a workbook that has a lot of sheets but i need to pull information from the one sheet "Veneer Log" i Need it to make new sheets with the same heading as on the "Veneer Log" (Rows 1 & 2) Sheet but it needs to be filtered by the "Product" Column (H) with a new sheet made for all the diffrent products i.e. Dimensional, Drywall, Corners - Thin V., Accents,..... so each product will have a new sheet with i am hoping someone can help me with this. This log changes Daily and it would be nice to have a sheet with only the same product on it to compare new orders so we can batch run. i hope i have given you enough information so someone can help me with this. i have attached a sample log the real log has about 10 worksheet for diffrent departments but i only need info from the Veneer Log Sheet.

View 14 Replies View Related

VBA - Delete Column If Cell Value Of Range Is Equal To Another Cell

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







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