View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Macro error when trying to open workbook

Works fine for me.

What is the error message type you get?


Gord Dibben MS Excel MVP

On Thu, 5 Nov 2009 15:08:06 -0800, paankadu
wrote:

I have been using this macro in several workbooks... each has a spearate
password and it has been working great... until I get to my latest workbook

I protect the sheets and have this code in the "This Workbook" so when it
opens it will update the date in each worksheet.. I have gone in and verified
my password for each sheet, have taken the protection off and put it back on
being very careful to make sure I am not misspelling anything, have changed
passwords and keep getting the same error. This is the same code I have used
in about 7 other workbooks (just changing the password for each one). I have
even deleted the code out and typed it in from scratch.

Anyone have any ideas why I am getting this error on only 1 workbook?


Private Sub Workbook_Open()
Dim Sh As Worksheet
For Each Sh In Sheets
With Sh
.Unprotect Password:="bear"
.Range("g2") = Date
.Protect Password:="bear"
End With
Next
End Sub