LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default protecting range with macro

I have a macro button that opens up multiple workbooks. I need it to
also protect a range of columns IE Column A - Column F. Each workbook
can have different number of rows so protecting the whole column is
probably easiest. The sheet within that workbooks can have different
names (not sheet1 but other names in it, not sure if that makes a
difference.


When I run this code all of the cells are protected not the range I
specify. What am I doing wrong?????

Here is my code
Sub Button1_Click()
Dim sPath As String, sName As String
Dim bk As Workbook
Dim ws As Worksheet
sPath = "C:\test\"
sName = Dir(sPath & "*.xls")
Do While sName < ""
Set bk = Workbooks.Open(sPath & sName)

For Each ws In bk.Worksheets
ws.Range("A1:F10").Locked = True
ws.Protect Password:="test", DrawingObjects:=True, Contents:=True,
Scenarios:=True


Next ws
sName = Dir
Loop
End Sub

 
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
Protecting the Print Range. becky Excel Discussion (Misc queries) 3 April 30th 09 06:05 PM
Protecting a Range of Specific Cell/s Blacksmith[_2_] Excel Discussion (Misc queries) 1 August 27th 07 04:43 PM
Protecting a Range in a list John Excel Programming 3 September 16th 06 01:53 PM
Protecting a Used Range Paige Excel Programming 2 March 16th 06 12:16 AM
Protecting Range Names Frederick Chow Excel Discussion (Misc queries) 4 March 8th 06 12:09 PM


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