Problem With Auto Open

G

Graham

Hi,
I have the following code running with Auto Open, but the
procedure does not seem to be working. It looks as if it's
skipping straight to the user form display at the end. I
guess there's something wrong with my "if" statement, but
I don't know what it is. Any help gratefully received!

Thanks
Graham

If LCase(ThisWorkbook.Name) = "READYRECKONER.xls" Then

Sheets("READY RECKONER").Visible = True
Sheets("READY RECKONER").Select
Sheets("READY RECKONER").Protect
DrawingObjects:=False, Contents:=False, Scenarios:=False

Range("CONTRACT_LENGTH").Select
Selection.ClearContents
Range("NO_OF_TEMPS").Select
Selection.ClearContents
Range("DAILY_HOURS").Select
Selection.ClearContents
Range("PAY_RATE").Select
Selection.ClearContents
Range("ENTER_MARGIN").Select
Selection.ClearContents
Range("ENTER_MARKUP").Select
Selection.ClearContents
Range("ENTER_FIXED").Select
Selection.ClearContents

Sheets("READY RECKONER").Protect DrawingObjects:=True,
Contents:=True, Scenarios:=True
Sheets("READY RECKONER").Visible = False

Sheets("ROLLING PENNY").Visible = True
Sheets("ROLLING PENNY").Select
Sheets("READY RECKONER").Protect
DrawingObjects:=False, Contents:=False, Scenarios:=False


Range("Q12").Select
ActiveCell.FormulaR1C1 = "1"
Range("S12").Select
ActiveCell.FormulaR1C1 = "1"

Range("A1").Select

Sheets("READY RECKONER").Protect DrawingObjects:=True,
Contents:=True, Scenarios:=True
Sheets("ROLLING PENNY").Visible = False

End If

' Display the Ready Reckoner Input Form

ReadyReckoner.Show
 
P

Pete McCosh

Graham,

my guess would be that

If LCase(ThisWorkbook.Name) = "READYRECKONER.xls" Then

is never going to be true. I think you probably meant to
use "UCase"! However, you'll need to capitalise ".XLS" as
well or it still wont match.

Alternatively, put an extra line in your declarations:

Option Compare text

Then you wont need to worry about case sensitivity at all.

Cheers, Pete
 
G

Guest

According to the option (i.e. : Option Compare Text) define in the top of your module the string comparaison of the if...then may not work as you want. In the following code I convert everything to uppercase
Nico
---------------------------------------------------------------------------
If UCase(ThisWorkbook.Name) = "READYRECKONER.XLS" The
Sheets("READY RECKONER").Visible = Tru
Sheets("READY RECKONER").Activat
Sheets("READY RECKONER").Unprotect 'no passwor

Range("CONTRACT_LENGTH")..ClearContent
Range("NO_OF_TEMPS").ClearContent
Range("DAILY_HOURS").ClearContent
Range("PAY_RATE").ClearContent
Range("ENTER_MARGIN").ClearContent
Range("ENTER_MARKUP").ClearContent
Range("ENTER_FIXED").ClearContent

Sheets("READY RECKONER").Protect ,True, True, True 'no passwor
Sheets("READY RECKONER").Visible = Fals

Sheets("ROLLING PENNY").Visible = Tru
Sheets("ROLLING PENNY").Activat
Sheets("ROLLING PENNY").unProtect 'no passwor

Range("Q12").Value = "1
Range("S12").Value = "1
Range("A1").Selec

Sheets("ROLLING PENNY").Protect , True, True, True 'no passwor
Sheets("ROLLING PENNY").Visible = Fals
End I

'Display the Ready Reckoner Input For
ReadyReckoner.Show
 
F

Frank Kabel

Hi Graham
change the line
If LCase(ThisWorkbook.Name) = "READYRECKONER.xls" Then

to
If UCase(ThisWorkbook.Name) = "READYRECKONER.XLS" Then
 
D

Dave Peterson

One more option (I like Option Compare Text, though):

If LCase(ThisWorkbook.Name) = "READYRECKONER.xls" Then
to
If LCase(ThisWorkbook.Name) = lcase("READYRECKONER.xls") Then

or even
If StrComp(ThisWorkbook.Name, "readyreckoner.xls", vbTextCompare) = 0 Then
 

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