Macro for running on preotected sheets

Y

Yogin

Hi All,

I am using the code below but when I protect the sheet it doesn't work, can
someone help on this problem please.

Sub TeamLeadersLates()

Dim MyDate As Date, StringDate As String
With Sheets("Daily Sheet")
StringDate = InputBox("Enter Date")
If IsDate(StringDate) Then
MyDate = DateValue(StringDate)

.Range("E2") = MyDate
Else
MsgBox "Invalid Date"
Exit Sub
End If

.Range("$B$4:$D$1000").AutoFilter Field:=1
.Range("$B$4:$D$1000").AutoFilter Field:=4
.Range("$B$4:$D$1000").AutoFilter Field:=4, Criteria1:="LTL"

Sheets("Daily Sheet").Select
End With
End Sub
 
M

Mike H

Hi,

Unprotect and then re-protext the sheet at runtime

Sheets("Daily Sheet").Unprotect Password:="Mypass"

'Your code
Sheets("Daily Sheet").Protect Password:="Mypass"

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top