Hi there, I was here asking questions yesterday about my workbook_open macro
(correctly placed in ThisWorkbook). The code is below, and I'm stumped. Some
parts work and some don't - and previously the parts that don't work did,
while the parts that do didn't.
Is there something about this special macro that I'm just not getting? The
book contains two worksheets, "Audit" and "Profiles". The code is supposed to
activate the Audit worksheet, record the user, the time and date that a new
workbook is created from a template, enter a random number that determines
whether the workbook is QC'd later on, protect the Audit worksheet with a
random password, hide it, and then return to the Profiles worksheet. If the
sheet is not new (i.e. contains the random number), it should bypass all that.
I changed it a bit yesterday following advice from the group, and now the
lines I've folowed with a * don't work anymore, but in older versions have
functioned perfectly well. I'm working in Excel 2000.
-------------
Private Sub Workbook_Open()
Sheets("Audit").Select
*used to work (as far as I know)
' If Sheets("Audit").Range("E2").Value = "New" Then
*Commented out yesterday - but putting it back doesn't help!
If Len(Sheets("Audit").Range("D2").Value) = 0 Then
Sheets("Audit").Range("A2").Value = Application.UserName
Sheets("Audit").Range("B2").Value = Date
Sheets("Audit").Range("C2").Value = Time
Randomize
Sheets("Audit").Range("D2").Value = Rnd()
*
'ActiveSheet.Protect Password:="A" & Int(Rnd() * 10000000000#)
'ActiveSheet.Visible = False
Sheets("Audit").Protect Password:="A" & Int(Rnd() * 10000000000#)
Sheets("Audit").Visible = False
*neither of these code variants work, the code previous contained the first
two lines, and worked fine
End If
Sheets("Profiles").Select
End Sub
------------------------
Feeling dim, and grateful for some advice,
Geoff.
Bookmarks