Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 -----Original Message----- 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 . |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Graham
change the line If LCase(ThisWorkbook.Name) = "READYRECKONER.xls" Then to If UCase(ThisWorkbook.Name) = "READYRECKONER.XLS" Then -- Regards Frank Kabel Frankfurt, Germany Graham wrote: 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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 Graham wrote: 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 -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Auto Open problem | Excel Discussion (Misc queries) | |||
auto open message | New Users to Excel | |||
Auto Open | Excel Discussion (Misc queries) | |||
Auto Open won't die or go away | Excel Programming | |||
Auto Open | Excel Programming |