Delete Sheets Based On List Using VB

Dec 19, 2008

I'm trying to delete sheets based on a list in Excel 2003 using VB, any ideas how to accomplish it as the various ways I've tried haven't even come close to working!

View 2 Replies


ADVERTISEMENT

Delete Rows Based On Value In Multiple Sheets?

Apr 2, 2014

I have the following code to delete rows based on the value "No" in cloumn "L". This code should loop through all sheets and delete the corresponding rows.

[Code]....

The code works perfectly but with one little issue. It fails in the first run always with the following error message.

VBA error.png

I need to comment out the line

[Code] ....

continue it with a breakpoint to "End With", remove the comment. Then it loops all worksheets and deletes the rows.

There is no protection or similiar on any sheet.

View 1 Replies View Related

Hide And Delete Sheets Based On Cell Input?

Aug 11, 2014

I have a situation where i would like to hide and delete a few sheets in my worksheet.

there is a few sheets where i want it to be constantly visible and one sheet is based on a cell reference.

the remaining irrelevant sheets i would like it to be hidden and deleted.

'always visible are sheets that are constantly visible in all files' 'visible msds is the sheet where my product data is being pulled out based on a input i enter on my first sheet' the sheets i want to hide and delete will be the remaining irrelevant "MSDS" that i would like to remove through macro.

View 3 Replies View Related

Delete Columns From All Sheets Based On Condition In X Workbooks

Mar 28, 2008

I am sure this is a very simple questions. I am using the below code to work on the worksheets on a workbook called "MF BANK EXPOSURE SUMMARY.xls" so far the code that I am using is:

Sub Commandbutton2()
Dim iCol As Long
Dim Isheet As Long
Dim Item As Worksheet
Set MFBANK = Workbooks("MF BANK EXPOSURE SUMMARY.xls")
For Each Item In MFBANK.Worksheets
With Item. Range("A1:T65536")
For iCol = .Column + .Columns.Count - 1 To 1 Step -1
If IsEmpty(.Cells(65536, iCol)) And IsEmpty(.Cells(1, iCol)) Then
If .Cells(65536, iCol).End(xlUp).Row = 1 Then .Columns(iCol).Delete
End If

Next iCol
End With
Next Item

End Sub

I would like to extend the code so that it works on the worksheets of two workbooks at the same time the one being the "MF BANK EXPOSURE SUMMARY.xls" and the other being "MF CP EXPOSURE SUMMARY.xls" .

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

Select Multiple Sheets Based On List

Oct 24, 2008

File attached to show problem

How do I select all the sheets that are Marked Y in column B when the button is clicked?

View 11 Replies View Related

Naming The Sheets Based On List On Column A.

May 5, 2006

I have a huge db that has a column "C" with a list of names. I have been creating tabs and naming them according to that list. I wonder if there is anyway I can create and name the tabs automatically. I already searched for threads in the forum, but only found this this backwards "tabs to cells". By the way, the names in column "C" sometimes repeat.

View 2 Replies View Related

Populate Cells On Multiple Sheets Based On List

Jun 26, 2013

I am having a hard time searching for this formula.

Sheet1 has the following data in A1:A5

value1
value2
value3
value4
value5

I then have 5 additional sheets.

I want to populate cell D2 on each additional sheet with the values from Sheet1

Sheet2 - Value1 in "D2"
Sheet3 - Value2 in "d2"

and so on...

View 4 Replies View Related

Copy/Move Rename Sheets Based On List

Aug 11, 2006

I have a list of names in sheet1, starting with cell A3. I would like to copy sheet3, insert it after sheet3 and rename the sheet to correspond to the names in the list.

If i have 30 names I would like 30 sheets. If i add a name, I would like to repeat the copy, insert and rename steps for the extra names as i add them.

View 7 Replies View Related

Generate A Dynamic List Of Employees On Sheets Based On Information?

Mar 26, 2014

I would like to generate a dynamic list of employees on sheets based on information on Sheet A. Here is my workbook structure:

-Sheet A contains all employees information (Name, division, salary hire date, etc)

-Sheet B is named Div A

-Sheet C is named Div B

-Etc...

Here is what I want to happen:

-Sheets B should pull the employees name and salary from sheet A only for employees of division A

-Sheet C should pull the employees name and salary from sheet A only for employees of division B

-Etc..

Sheet B, C , etc. should update the info and resort every time sheet A is updated.

View 5 Replies View Related

Excel Macro To Create New Workbook Based On Category In List With Respective Sheets

Apr 27, 2014

I need new workbooks based on category name in the below list. Respective sheets should be copied from the existing workbook with items as sheet names. List can be updatable.

category(workbookname)Items(sheets)
Vegetables carrot
vegetables brinjal
meat chicken
meat Fish
meat Mutton
grains Wheat
grains Rice

View 4 Replies View Related

Delete Chart Series Across Sheets But Skip Protected Sheets

Mar 30, 2008

I have received following macro from someone to delete series but the problem is that it gives error when some sheets are protected, and I want those sheets to protected. When run it will ignore/leave protected sheets but delete series only from unprotected sheets

Private Sub CommandButton1_Click()
Dim Rng As Range, i As Long, r As Range, lVal, uVal
Dim DeleteCount As Double
Dim lRow As Long
Dim dr As Long
Dim dc As Long
dc = Sheets("Deleted Numbers").UsedRange.Columns.Count - 1
dr = Cells(Rows.Count, Sheets("Deleted Numbers").UsedRange.Columns.Count - 1).End(xlUp).Row + 1
If dr = 60001 Then ................

View 4 Replies View Related

Delete Rows Based On "other" List

Oct 29, 2008

I have a list of names in sheet1 that is 10k rows..
In sheet 2, I have a list of about 10 names.

I need to delete any rows in sheet 1, that matches any name in sheet 2.

Any ideas?

I know I can do this "if cells.value = "ALAN" then delete row
but how do you accomplish this without doing the above for every name.

I would like the VBA to work like this::

If cells.value = ( any name in the 2nd list ), then delete row.

View 9 Replies View Related

Excel 2010 :: Can't Delete Filtered / Visible List Rows From List Object

May 19, 2014

I have pulled a SharePoint list into my workbook. The list object (table) is still linked to the SharePoint list, as I'd like to synchronize it later on. I have filtered it with an autofilter. I'd like to delete all of the visible rows. I have tried a billion things to no avail. I have been searching Google for hours now. None of the examples work.

View 5 Replies View Related

Delete Value Of Dependent List Automatically When Mother-list Gets Manually Deleted?

Feb 8, 2013

I'm currently working with 3 dropdown lists depending on each other using data validation and =indirect(). I arranged them like in a top-down approach where you have a mother-list and child-lists (categories-->subCategories-->subCategoryCriteria). The user should easily chose first a category then a subCategory etc... This part works perfectly

My question is: when a user chose in the dropdown list e.g. a category, a subCategory and a subCategoryCriteria and he now maually deletes the value in the highest level, which is the Category (mother-list), all sub level values like subCategory and subCategoryCriteria will stay. It shouldn't be that way, because it's not logical. If you turn a tree upside-down (top-down approach) and cut one of the higher positioned trunks, all lower positioned trunks will fall off as well, right? So, my question is: can I use a conditional formatting or a formula to delete or fade out the value in the lower lists when the higher list value is being deleted?

I tried to use If-formula in combination with indirect in data validation, like =IF(A1="";("");INDIRECT(B1))...just and example.

The value doesnt need to be deleted, it could also be automatically face out like white on white or something. It's just confusing for the user if he deletes the highest choice and the lower choices still stay.

View 8 Replies View Related

Duplicates - Delete Every Lead On List A Whose Email Address Is Also In List B?

Jan 9, 2014

I am working on an email marketing project and i have a small problem. I have two different email list. One (List A) is a large list of potential leads. The other (List B) is a list of leads we are not supposed to market to. I need to delete every lead on List A whose email address is also in List B, so that we do not send unwanted emails to our clients.

The best way i have to do this so far is to go through line by line, which is very impractical.

In case it matters here is out list format. Each list has 10,000 + leads. Each lead occupies a row. The row stretches across 13 columns and each column holds a different variable about the lead (names, state, email address).

View 2 Replies View Related

Delete All Sheets Except One

Nov 25, 2009

I want to delete all sheets except for one named "Start"

View 3 Replies View Related

Delete Row In All Sheets

Mar 6, 2012

I need to delete Row 1 of all on all open sheets in a workbook(meaning that hidden sheets should not be affected).

View 1 Replies View Related

Delete Some Of The Sheets?

Apr 30, 2013

code that would read the current spreadsheet names of the workbook and then delete some of those sheets.For example the current sheet names are:

Input
Budget12
Budget13
Sheet4
Sheet5
Sheet6

The code needs to delete all the sheets other than the following: Input, Budget12, Budget13. if the code could ignore sheet name that contains text "Budget" rather than ignoring Budget12 and Budget13. That would make it more dynamic.

View 2 Replies View Related

Delete (2) From Sheets Name

Apr 6, 2009

How sould I remove (2) from sheets names

Like sheet1(2) change into sheet1

View 9 Replies View Related

Delete All (except One) Sheets

Jun 2, 2009

I would like to delete all except one sheets in the workbook by pressing onto a button. So I wrote the folllowing code (its obviously only a part)

Application.DisplayAlerts = False
For Each Worksheet In Worksheets
If (Worksheet.Name "Instructions") Then
Worksheet.Delete
End If
Next
Application.DisplayAlerts = True

and put it into a Module in the same workbook. The button itself is in one of the sheets to be deleted, so I assign a simple macro to it which is just calling the code above.

Well, sounds simple, but it does not work, with "Subscript out of range" error at the attempt to delete one (not the first one) of the sheets.

Searching around suggested that the problem appears when the worksheet I try to access does not exist (missspelling of a name or so). but in my code I dont really use it.

View 9 Replies View Related

VB Code To Add And Delete Row From Sheets

Mar 27, 2014

I would like to add 2 buttons to each page. One button to add a row at the bottom of the table while keeping all of the same formatting and another button to Delete a selected row from the table. So that if there is more assignments than allowed in the current table, a row could easily be added.

I would think that the code for the class sheets would all be the same.

The other obstacle I thought about is possible making a button on the Summary page that would add another sheet, call it Class and whatever number comes next and also add it to the summary table with the same formatting (including the hyperlink that's in the Classes column where it will take you to the Class sheet that you want to drill down to).

I have attached the file. If the summary sheet is took much work it's not a big deal, I would be fine with just being able to have 2 buttons on the class sheets that allowed them to add and remove and such.

I would also like to contribute. I know a decent amount about SQL and SSRS/SSIS Reporting services.

I also need it to be able to unprotect my worksheet and then protect it back, Since I will only want them to be able to type in the areas I specify. I also moved the summary at the bottom of each class sheet to the right side at the top so its easier for them to view.

View 5 Replies View Related

Delete 7 Cells On Each Of The 35 Sheets

Aug 12, 2008

i am going to have 25 sheets for subcontractors in a construction magement workbook. i want to delete 7 cells on each of the 35 sheets. they will all be in the same place on all sheets. ex c7 g18 e14 etc on all 25 sheets. i was wondering if there is a way to create a function that can perform this operation.

View 13 Replies View Related

Delete Sheets Without Warning

Jul 29, 2009

For instance: Sheets(sheets.count).delete. I delete the last sheet, but I dont want a message box warning. Can i disable that with vba code? (offcource I can, but how?)

View 2 Replies View Related

Delete Row With 0 In It Across All Sheets In Column A

May 23, 2013

Below is my code.

It opens a file, does nifty offset formula to compact rows A and B to rows E and F. The problem, is once it is done it leaves a trail of 0's in cells that had no data in the original file.

I have been trying to figure a way to just delete the rows in column A that have a zero in each worksheet (there are 7)

Code:
Option Explicit Private Sub CommandButton1_Click() Dim fromwb As Workbook Dim ws As Worksheet Application.ScreenUpdating = False ' Opens file to select With Application.FileDialog(msoFileDialogOpen) .Filters.Clear .Filters.Add "Excel 2007",

[Code].....

View 6 Replies View Related

VBA To Delete All Hidden Sheets?

Aug 21, 2013

I just came across file that needs to be cleaned up. Problem is, the main summary references more than 50 hidden sheets for pay periods dating back to 2011.

I want to make everything values from previous pay periods then get rid of the hidden sheets.

View 4 Replies View Related

Delete Rows Of Other Sheets Also

Jun 23, 2007

I have a WB where the first sheet is "Introduction", second is "Master Data" wherein the name of players with some details are kept.

After that some sheets are there which are linked to "Master Data" ie say Sheet2,sheet3,Sheet5 (sheet 4 is not linked to "Master data" but appears after sheet3)

I want that if a record , say record 3 at row 5 is deleted also delete that record 3 in other linked sheets ie Sheet2,sheet3,Sheet5 The positions of the records differ from sheet to sheet ie if record 3 is at row 5 of master sheet it coulsd be on row 8 of sheet2, at row 10 of sheet3 & at row 6 of sheet 5. All the name of the person are linked to sheets with =masterdata!B5 like this.

View 9 Replies View Related

Trying To Delete Unneeded Sheets With VBA

Oct 30, 2007

I have tried the following two sets of codes trying to delete unneeded sheets with VBA.

1) Application.ActiveWorkbook.Sheets("PART").DELETE

2) Sheets("PART").Select
ActiveWindow.SelectedSheets.Delete

Neither of these deletes the sheets when I run my macro. I have Application.DisplayAlerts = False. Don't know whether that has anything to do with it.

View 9 Replies View Related

VBA To Delete Sheets When Save As

Aug 26, 2008

I have plenty of sheets in my spreadsheet but I need some of the sheets to be deleted before it can be sent to client due to sensitive data. Just to be proactive, some time I may not delete the sheet/s before I send it to client...and that means I am fired from my job.

How is it possible that before I save as my master spreadsheet, excel deletes some of the sheets (Names: "Cost", "Contacts","Vendor"), etc.

View 9 Replies View Related

Delete Sheets Macro

Jan 31, 2009

I have a macro on: Sheet101 (DAY 1) that adds additional sheets.
Example: When I click active button it will add Sheet102 (DAY 2) & can add up to Sheet130 (DAY 30)

I want a macro that will delete any of the sheets added from Sheet102 (DAY 2) up to Sheet130 (DAY 30) But WON'T Delete Sheet101 (DAY 1)

Example:
If I have added 3 sheets I want it to delete those 3 Sheets:
Sheet101 (DAY 1)

View 9 Replies View Related







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