Home > Software engineering >  For help, how to delete eligible sheet form excel
For help, how to delete eligible sheet form excel

Time:09-20

My experiment summary table there are more than ten sheet table, window text box filter conform to the conditions of the experimental group format for: * * * *. CSV, * * * *. CSV;
* * * *. CSV, * * * *. CSV;
* * * *. CSV, * * * *. CSV;
Every * * * *. CSV a sheet form name, text box is divided into three lines, how can I get a one-time delete summary form in addition to the inside of the text box the six eligible group sheet, the original code, thank you!

CodePudding user response:

Cannot "one-off" delete, only one by one to delete,
Even Excel itself, does not support "a delete multiple tables,"

The For loop, enumerated all forms, in accordance with the "name" (form "text label", not the actual object name),
Name is not in "text box of the six eligible group sheet" within it deletes,

CodePudding user response:

Just for a few days ago the wife wrote a macro contains to delete the sheet accord with certain conditions, the loop to a delete a jump every time a confirmation dialog, therefore, then recorded a Duan Hong modification, there is the general practice of eligible sheet was select, and choose a heap, then one breath to delete all of the selected sheet, this confirmation dialog box will pop up a times,
Post code, but you want to change, or executive complains, particular way to see the comments in the code
Hope useful to you,
 
Private Sub clean sheet ()
Dim col As New Collection
Dim ary () As String
'first put the names of all the eligible sheet in a collection
For Each isheet In wb. Sheets
If isheet. Name & lt;> "Course information" And isheet. Name & lt;> "Stores information" And isheet. Name & lt;> "Budget adjustments format" Then
Col. Add isheet. Name
End the If
Next
'if the collection number greater than zero, shows the sheet need to delete the
If col. Count & gt; 0 Then
'definition of an array, in the collection of the sheet name, of course, also can need not so complicated, in the above judgment eligible sheet name can do this, but I don't want to frequent redim array, it is a personal eccentricities not worth learning,
ReDim ary (0 To col. Count - 1)
For I=0 To col. Count - 1
Ary (I)=col (I + 1)
Next
'this wb is workbook, I define a global variable to put work workbook, here's the code you need to change,
Wb. Activate
'threw an array, a pile of sheet selected
Wb. Sheets (ary). Select
'the chosen sheet are deleted,
ActiveWindow. SelectedSheets. Delete
End the If
End Sub
  • Related