Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Protecting the Print Range. | Excel Discussion (Misc queries) | |||
Protecting a Range of Specific Cell/s | Excel Discussion (Misc queries) | |||
Protecting a Range in a list | Excel Programming | |||
Protecting a Used Range | Excel Programming | |||
Protecting Range Names | Excel Discussion (Misc queries) |