View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Macro for running on preotected sheets

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

"Yogin" wrote:

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