#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default On load

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default On load

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default On load

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default On load

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default On load

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default On load

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I load an Add-ins Erin Excel Discussion (Misc queries) 4 November 11th 06 01:12 AM
Cannot load book12 Excel Discussion (Misc queries) 1 November 11th 05 12:01 AM
XLA will not load [email protected] Excel Programming 1 October 27th 04 05:46 PM
load an add-in in VBA dibdab Excel Programming 1 March 3rd 04 05:11 AM
How to load another XLL in the XLL? Michael[_18_] Excel Programming 0 October 18th 03 01:49 PM


All times are GMT +1. The time now is 02:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"