Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Sal Sal is offline
external usenet poster
 
Posts: 84
Default Macro to delete unwanted sheets

Hi there,
I am creating a questionnaire type form which has a separate sheet for
different subjects, each sheet has a rating total at the bottom. I am
looking for a macro which will scan the entire workbook and delete those
sheets that have a total of 0 at the bottom.

Also these figures are consolidated into a final worksheet and I would like
to be able to delete any columns that relate to the deleted workbooks above.

Many thanks.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Macro to delete unwanted sheets

Lets say that the rating total is in cell A20 in each sheet. Then the
following macro is delete all sheets that have zero in that cell:


Sub rmsheet()
k = Sheets.Count
Application.DisplayAlerts = False
For i = k To 1 Step -1
If Sheets(i).Range("A20") = 0 Then
Sheets(i).Delete
End If
Next
Application.DisplayAlerts = True
End Sub

--
Gary''s Student
gsnu200710


"Sal" wrote:

Hi there,
I am creating a questionnaire type form which has a separate sheet for
different subjects, each sheet has a rating total at the bottom. I am
looking for a macro which will scan the entire workbook and delete those
sheets that have a total of 0 at the bottom.

Also these figures are consolidated into a final worksheet and I would like
to be able to delete any columns that relate to the deleted workbooks above.

Many thanks.

  #3   Report Post  
Posted to microsoft.public.excel.misc
Sal Sal is offline
external usenet poster
 
Posts: 84
Default Macro to delete unwanted sheets

I will give it a try - thanks very much

"Gary''s Student" wrote:

Lets say that the rating total is in cell A20 in each sheet. Then the
following macro is delete all sheets that have zero in that cell:


Sub rmsheet()
k = Sheets.Count
Application.DisplayAlerts = False
For i = k To 1 Step -1
If Sheets(i).Range("A20") = 0 Then
Sheets(i).Delete
End If
Next
Application.DisplayAlerts = True
End Sub

--
Gary''s Student
gsnu200710


"Sal" wrote:

Hi there,
I am creating a questionnaire type form which has a separate sheet for
different subjects, each sheet has a rating total at the bottom. I am
looking for a macro which will scan the entire workbook and delete those
sheets that have a total of 0 at the bottom.

Also these figures are consolidated into a final worksheet and I would like
to be able to delete any columns that relate to the deleted workbooks above.

Many thanks.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 303
Default Macro to delete unwanted sheets

And this one will also delete the column

Greetings from New Zealand


Sub deletesheet()
Dim number As Integer
Dim coldelete As Integer
coldelete = -1
number = 2 'you can change this starting number to suit
'my first sheets' result was in column "D" of sheet1
Sheets("sheet1").Select 'assuming that the summary is on sheet1
Application.DisplayAlerts = False
For Each Sheet In Sheets
Sheet.Select
number = number + 1
If Range("A6").Value = 0 Then 'change this range to suit
ActiveSheet.Delete
coldelete = coldelete + 1
Sheets("sheet1").Select
Columns(number - coldelete).Delete
End If
Next
Application.DisplayAlerts = True
Sheets("sheet1").Select
End Sub

"Sal" wrote in message
...
I will give it a try - thanks very much

"Gary''s Student" wrote:

Lets say that the rating total is in cell A20 in each sheet. Then the
following macro is delete all sheets that have zero in that cell:


Sub rmsheet()
k = Sheets.Count
Application.DisplayAlerts = False
For i = k To 1 Step -1
If Sheets(i).Range("A20") = 0 Then
Sheets(i).Delete
End If
Next
Application.DisplayAlerts = True
End Sub

--
Gary''s Student
gsnu200710


"Sal" wrote:

Hi there,
I am creating a questionnaire type form which has a separate sheet for
different subjects, each sheet has a rating total at the bottom. I am
looking for a macro which will scan the entire workbook and delete
those
sheets that have a total of 0 at the bottom.

Also these figures are consolidated into a final worksheet and I would
like
to be able to delete any columns that relate to the deleted workbooks
above.

Many thanks.



  #5   Report Post  
Posted to microsoft.public.excel.misc
Sal Sal is offline
external usenet poster
 
Posts: 84
Default Macro to delete unwanted sheets

thank you very much

"Bill Kuunders" wrote:

And this one will also delete the column

Greetings from New Zealand


Sub deletesheet()
Dim number As Integer
Dim coldelete As Integer
coldelete = -1
number = 2 'you can change this starting number to suit
'my first sheets' result was in column "D" of sheet1
Sheets("sheet1").Select 'assuming that the summary is on sheet1
Application.DisplayAlerts = False
For Each Sheet In Sheets
Sheet.Select
number = number + 1
If Range("A6").Value = 0 Then 'change this range to suit
ActiveSheet.Delete
coldelete = coldelete + 1
Sheets("sheet1").Select
Columns(number - coldelete).Delete
End If
Next
Application.DisplayAlerts = True
Sheets("sheet1").Select
End Sub

"Sal" wrote in message
...
I will give it a try - thanks very much

"Gary''s Student" wrote:

Lets say that the rating total is in cell A20 in each sheet. Then the
following macro is delete all sheets that have zero in that cell:


Sub rmsheet()
k = Sheets.Count
Application.DisplayAlerts = False
For i = k To 1 Step -1
If Sheets(i).Range("A20") = 0 Then
Sheets(i).Delete
End If
Next
Application.DisplayAlerts = True
End Sub

--
Gary''s Student
gsnu200710


"Sal" wrote:

Hi there,
I am creating a questionnaire type form which has a separate sheet for
different subjects, each sheet has a rating total at the bottom. I am
looking for a macro which will scan the entire workbook and delete
those
sheets that have a total of 0 at the bottom.

Also these figures are consolidated into a final worksheet and I would
like
to be able to delete any columns that relate to the deleted workbooks
above.

Many thanks.






  #6   Report Post  
Posted to microsoft.public.excel.misc
Sal Sal is offline
external usenet poster
 
Posts: 84
Default Macro to delete unwanted sheets

Hi Gary,

I tested this out but the code fell over at line:
Sheets(i).Delete

Dont really know enough about VBA to work out the problem.

Cheers



"Gary''s Student" wrote:

Lets say that the rating total is in cell A20 in each sheet. Then the
following macro is delete all sheets that have zero in that cell:


Sub rmsheet()
k = Sheets.Count
Application.DisplayAlerts = False
For i = k To 1 Step -1
If Sheets(i).Range("A20") = 0 Then
Sheets(i).Delete
End If
Next
Application.DisplayAlerts = True
End Sub

--
Gary''s Student
gsnu200710


"Sal" wrote:

Hi there,
I am creating a questionnaire type form which has a separate sheet for
different subjects, each sheet has a rating total at the bottom. I am
looking for a macro which will scan the entire workbook and delete those
sheets that have a total of 0 at the bottom.

Also these figures are consolidated into a final worksheet and I would like
to be able to delete any columns that relate to the deleted workbooks above.

Many thanks.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting unwanted data by macro or... Leibtek Excel Discussion (Misc queries) 2 August 14th 06 05:22 PM
How do I delete unwanted extra pages on Excel worksheets RogerD Excel Discussion (Misc queries) 4 May 20th 06 11:53 PM
Delete unwanted page breaks. Tionne Excel Worksheet Functions 1 February 21st 06 03:38 PM
How do i delete a macro in Excel 2003 when delete isn't highlight Abel Excel Discussion (Misc queries) 2 September 13th 05 04:09 AM
Delete Unwanted Data Happy Excel Discussion (Misc queries) 1 August 17th 05 06:20 AM


All times are GMT +1. The time now is 06:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"