Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
When my worksheet is loaded I want to default in the following statement:
Range("B2").Value = Date - 1 There does not appear to be an on load event (or I should be using something besides the worksheet). Please give suggestions on the event to use. as always, Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Private Sub Worksheet_Activate()
Me.Range("A1").Value = Date - 1 End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH Bob Phillips (remove xxx from email address if mailing direct) "Robert_DubYa" wrote in message ... When my worksheet is loaded I want to default in the following statement: Range("B2").Value = Date - 1 There does not appear to be an on load event (or I should be using something besides the worksheet). Please give suggestions on the event to use. as always, Thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you want the line to run when the workbook opens then go into the
ThisWorkBook class module, select workbook, and then open. It should look like this: Private Sub Workbook_Open Sheet1.Range("B2").Value = Date - 1 End sub If it is when the worksheet is activated then go into the sheets code, select worksheet, then the activate event. It should look like this: Private Sub Worksheet_Activate() Me.Range("B2").Value = Date - 1 End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Brian,
First let me thank you for your help. I am familiar with VB and use it in Access alot, but I can't seem to find the workbook class module. Could you please let me know where to look? thanks! "Brian Taylor" wrote: If you want the line to run when the workbook opens then go into the ThisWorkBook class module, select workbook, and then open. It should look like this: Private Sub Workbook_Open Sheet1.Range("B2").Value = Date - 1 End sub If it is when the worksheet is activated then go into the sheets code, select worksheet, then the activate event. It should look like this: Private Sub Worksheet_Activate() Me.Range("B2").Value = Date - 1 End Sub |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Go to the VBE editor (alt-F11). If you don't have a project explorer
window on the left hand side go to View and then select project explorer. Look for the name of your workbook. Expand the section. Then look for "ThisWorkBook". Double click on it. This should open the code section for the workbook module. At the top is a drop down that says "general". Select "Workbook" from that drop down. It should default to "open" in the next drop down and put some code in the code area. If it doesn't then select open from the events list. Insert your line of code in the workbook open event. This will cause whatever you put in to happen every time the workbook is opened. Private Sub Workbook_Open Sheet1.Range("B2").Value = Date - 1 End sub |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you want the line to run when the workbook opens then go into the
ThisWorkBook class module, select workbook, and then open. It should look like this: Private Sub Workbook_Open Sheet1.Range("B2").Value = Date - 1 End sub If it is when the worksheet is activated then go into the sheets code, select worksheet, then the activate event. It should look like this: Private Sub Worksheet_Activate() Me.Range("B2").Value = Date - 1 End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I load an Add-ins | Excel Discussion (Misc queries) | |||
Cannot load | Excel Discussion (Misc queries) | |||
XLA will not load | Excel Programming | |||
load an add-in in VBA | Excel Programming | |||
How to load another XLL in the XLL? | Excel Programming |