View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Macro for Deleting Worksheets

Say we are on the summary tab. Say each column is associated with a data
sheet tab. Say that row 1 contains the tabname:

A1 contains Sheet1
B1 contains Sheet2
C1 contains Sheet3
etc.

The user selects a column and runs:

Sub TabKiller()
s1 = ActiveSheet.Name
s2 = Selection(1).Value
For i = 1 To Columns.Count
v = Cells(1, i).Value
If v = "" Then Exit Sub
If v = s1 Or v = s2 Then
Else
Sheets(v).Delete
End If
Next
End Sub

--
Gary''s Student - gsnu200842


"andiam24" wrote:

Hi,

I am somewhat new to VBA so the simpler the better. I have a workbook with a
summary page and corresponding tabs for data entry. On the summary page the
user selects which columns to keep for data display. The columns retained
should correspond with the tabs as this is where the data from the tabs will
be displayed. Is it possible to use a macro to delete all tabs that do not
correspond to a column the user has selected? Any help would be great.