I have a macro that copies rows from one sheet to another. However, I want to protect this sheet from editing. When I do this though, I cant get the macro to run. I've played around with the different locked properties and it still doesn't work.
This is what Ive attempted:
Option Explicit
Dim pwd As String
Dim ws As Worksheet
pwd = "password"
ws.Unprotect password:=pwd
Next ws
Sub FilterAndCopy()
Dim rng As Range, sht1 As Worksheet, sht2 As Worksheet
Set sht1 = Worksheets("SHIFT LOG")
Set sht2 = Worksheets("CHANGE OF NO'S")
sht2.UsedRange.ClearContents
With Intersect(sht1.Columns("B:BP"), sht1.UsedRange)
.Cells.EntireColumn.Hidden = False
If .Parent.AutoFilterMode Then .Parent.AutoFilterMode = False
.AutoFilter Field:=1, Criteria1:="Change of Numbers"
.Range("A:F, AD:AD, BL:BO").Copy Destination:=sht2.Cells(4, "B")
.Parent.AutoFilterMode = False
.Range("F:AD").EntireColumn.Hidden = True
.Range("AE:BK").EntireColumn.Hidden = True
End With
'Go to last cell in column B
With ActiveSheet
Range("B5").Select
Selection.End(xlDown).Select
End With
End Sub
ws.Protect password:=pwd
Next ws