Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Selective Worksheet Deletion

I am just starting to learn about protecting workbook structure.

I'm building an application where the user can add and delete his/her own
worksheets.

There are other sheets in the app, however, that are protected and which I
do NOT ever want to be deleted, they have specific and un-changing worksheet
names.

I was surprised when I was able to delete a protected worksheet, so ......

What are some approaches to do what I want ?

Thanks,
Neal


--
Neal Z
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Selective Worksheet Deletion


Użytkownik "Neal Zimm" napisał w wiadomo¶ci
...
I am just starting to learn about protecting workbook structure.

I'm building an application where the user can add and delete his/her own
worksheets.

There are other sheets in the app, however, that are protected and which

I
do NOT ever want to be deleted, they have specific and un-changing

worksheet
names.

I was surprised when I was able to delete a protected worksheet, so ......

What are some approaches to do what I want ?

Thanks,
Neal


--
Neal Z



easist would be to hide your sheets ( if its not necessary to use them)
mcg



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Selective Worksheet Deletion

When you protect a sheet, you tell the user that they can't change unlocked
cells on that sheet.

But if you protect the workbook (with Windows checked), then the user can't
delete, insert, rename or move a worksheet.

And workbook protection like this doesn't affect what the user can do to any
cell on the worksheet.

I think I'd build a small userform with a listbox that only added the names of
the worksheets that can be deleted.

I put a listbox and two commandbuttons (ok/cancel) on a userform and had this
code behind it:

Option Explicit
Private Sub CommandButton1_Click()

Dim iCtr As Long
Dim myPWD As String

myPWD = "hi"

ActiveWorkbook.Unprotect Password:=myPWD

For iCtr = 1 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(iCtr) Then
Application.DisplayAlerts = False
On Error Resume Next
ActiveWorkbook.Worksheets(Me.ListBox1.List(iCtr)). Delete
On Error GoTo 0
Application.DisplayAlerts = True
End If
Next iCtr

ActiveWorkbook.Protect Password:=myPWD, Windows:=True

Unload Me

End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim wks As Worksheet
Me.ListBox1.MultiSelect = fmMultiSelectMulti
For Each wks In ActiveWorkbook.Worksheets
Select Case LCase(wks.Name)
Case Is = "sheet1", "sheet3", "sheet5"
'skip it
Case Else
Me.ListBox1.AddItem wks.Name
End Select
Next wks
End Sub


Neal Zimm wrote:

I am just starting to learn about protecting workbook structure.

I'm building an application where the user can add and delete his/her own
worksheets.

There are other sheets in the app, however, that are protected and which I
do NOT ever want to be deleted, they have specific and un-changing worksheet
names.

I was surprised when I was able to delete a protected worksheet, so ......

What are some approaches to do what I want ?

Thanks,
Neal

--
Neal Z


--

Dave Peterson
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
Selective printing of worksheet Zygy[_3_] New Users to Excel 3 October 11th 07 12:59 PM
Selective Deletion within a column Colin Hayes Excel Worksheet Functions 8 September 10th 06 03:27 AM
Selective Column deletion mattrane Excel Discussion (Misc queries) 4 December 25th 05 02:01 AM
Selective Column deletion mattrane Excel Discussion (Misc queries) 0 December 24th 05 09:47 PM
Selective deletion of rows containing certain text. Colin Hayes Excel Worksheet Functions 9 June 15th 05 10:41 PM


All times are GMT +1. The time now is 02:49 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"