Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Auto Copy Macro?

Hi,

I have an macro that would protect the sheet and allow insert/delete columns
and rows, as follow,

Sub Auto_Open()
With Worksheets("Sheet 1")
.Protect Password:="hi", userinterfaceonly:=True
.EnableOutlining = True
End With

ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
False, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowInsertingColumns:=True,
AllowInsertingRows _
:=True, AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, _
AllowDeletingRows:=True, AllowSorting:=True, AllowFiltering:=True, _
AllowUsingPivotTables:=True

End Sub

i would like to modify it so that when i duplicate "Sheet 1" to "Sheet 2",
"Sheet 3", Sheet 4".....and so on, the macro would still work on all sheets
that start with "Sheet", any idea?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Auto Copy Macro?

Option Explicit
Sub Auto_Open()
Dim wks As Worksheet

For Each wks In ThisWorkbook.Worksheets
If LCase(Left(wks.Name, 5)) = "sheet" Then
With wks
.Protect Password:="hi", userinterfaceonly:=True
.EnableOutlining = True
End With
End If
Next wks

End Sub

If you wanted all those other protection options:

Option Explicit
Sub Auto_Open()
Dim wks As Worksheet

For Each wks In ThisWorkbook.Worksheets
If LCase(Left(wks.Name, 5)) = "sheet" Then
With wks
.Protect Password:="hi", userinterfaceonly:=True, _
DrawingObjects:=False, Contents:=True, _
Scenarios:=False, AllowFormattingCells:=True, _
AllowFormattingColumns:=True, AllowFormattingRows:=True, _
AllowInsertingColumns:=True, AllowInsertingRows:=True, _
AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True,
_
AllowDeletingRows:=True, AllowSorting:=True, _
AllowFiltering:=True, AllowUsingPivotTables:=True
.EnableOutlining = True
End With
End If
Next wks

End Sub



Henry wrote:

Hi,

I have an macro that would protect the sheet and allow insert/delete columns
and rows, as follow,

Sub Auto_Open()
With Worksheets("Sheet 1")
.Protect Password:="hi", userinterfaceonly:=True
.EnableOutlining = True
End With

ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
False, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowInsertingColumns:=True,
AllowInsertingRows _
:=True, AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, _
AllowDeletingRows:=True, AllowSorting:=True, AllowFiltering:=True, _
AllowUsingPivotTables:=True

End Sub

i would like to modify it so that when i duplicate "Sheet 1" to "Sheet 2",
"Sheet 3", Sheet 4".....and so on, the macro would still work on all sheets
that start with "Sheet", any idea?

Thanks


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Auto Copy Macro?

Watch out for line wrap on that second sample.

Dave Peterson wrote:

Option Explicit
Sub Auto_Open()
Dim wks As Worksheet

For Each wks In ThisWorkbook.Worksheets
If LCase(Left(wks.Name, 5)) = "sheet" Then
With wks
.Protect Password:="hi", userinterfaceonly:=True
.EnableOutlining = True
End With
End If
Next wks

End Sub

If you wanted all those other protection options:

Option Explicit
Sub Auto_Open()
Dim wks As Worksheet

For Each wks In ThisWorkbook.Worksheets
If LCase(Left(wks.Name, 5)) = "sheet" Then
With wks
.Protect Password:="hi", userinterfaceonly:=True, _
DrawingObjects:=False, Contents:=True, _
Scenarios:=False, AllowFormattingCells:=True, _
AllowFormattingColumns:=True, AllowFormattingRows:=True, _
AllowInsertingColumns:=True, AllowInsertingRows:=True, _
AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True,
_
AllowDeletingRows:=True, AllowSorting:=True, _
AllowFiltering:=True, AllowUsingPivotTables:=True
.EnableOutlining = True
End With
End If
Next wks

End Sub

Henry wrote:

Hi,

I have an macro that would protect the sheet and allow insert/delete columns
and rows, as follow,

Sub Auto_Open()
With Worksheets("Sheet 1")
.Protect Password:="hi", userinterfaceonly:=True
.EnableOutlining = True
End With

ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
False, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowInsertingColumns:=True,
AllowInsertingRows _
:=True, AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, _
AllowDeletingRows:=True, AllowSorting:=True, AllowFiltering:=True, _
AllowUsingPivotTables:=True

End Sub

i would like to modify it so that when i duplicate "Sheet 1" to "Sheet 2",
"Sheet 3", Sheet 4".....and so on, the macro would still work on all sheets
that start with "Sheet", any idea?

Thanks


--

Dave Peterson


--

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
Auto-populate, Auto-copy or Auto-fill? Jay S. Excel Worksheet Functions 4 August 10th 07 09:04 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Saving a copy of excel file in macro but have it auto write pano Excel Worksheet Functions 4 March 27th 07 11:54 PM
is there a way to auto copy cells similar to auto sum? saki4two Excel Worksheet Functions 1 January 11th 06 08:21 PM
auto copy PROXY Excel Programming 1 September 9th 03 01:49 PM


All times are GMT +1. The time now is 01:44 PM.

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

About Us

"It's about Microsoft Excel"