Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Automatic Dates

Is there a way of automatically entering today's date so that it does
not change when the program is opened on a later date. I tried the
TODAY() command but that updates the date to the current date.

Orf Bartrop

  #2   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Automatic Dates

Try: Ctrl + ;

--
Rgds
Max
xl 97
---
Please respond, in newsgroup
xdemechanik <atyahoo<dotcom
----
"Orf Bartrop" wrote in message
...
Is there a way of automatically entering today's date so that it does
not change when the program is opened on a later date. I tried the
TODAY() command but that updates the date to the current date.

Orf Bartrop



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Automatic Dates

Hi Orf,

VBA will do it

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:H10")) Is Nothing Then
With Target
.Value = Format(Date, "dd mmm yyyy")
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

This is worksheet event code, so right-click the sheet tab, select View
Code, and paste the code in.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Orf Bartrop" wrote in message
...
Is there a way of automatically entering today's date so that it does
not change when the program is opened on a later date. I tried the
TODAY() command but that updates the date to the current date.

Orf Bartrop



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Automatic Dates

Thanks, Bob. I did as you directed and came up with an error:
Compile error: Ambiguous name detected: Worksheet-Change

I think this is happening because there is already a statement:
Private Sub Worksheet_Change(ByVal Target As Range
followed by End Sub (nothing between).

I tried deleting those two statements but then data entered in the sheet
was not correct.

I do not know what wording to change to get it to work.

Orf

Bob Phillips wrote:

Hi Orf,

VBA will do it

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:H10")) Is Nothing Then
With Target
.Value = Format(Date, "dd mmm yyyy")
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

This is worksheet event code, so right-click the sheet tab, select View
Code, and paste the code in.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Automatic Dates

Orf,

Your reasoning is correct.

Post the 2 change event codes and I will try and merge them for you.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Orf Bartrop" wrote in message
...
Thanks, Bob. I did as you directed and came up with an error:
Compile error: Ambiguous name detected: Worksheet-Change

I think this is happening because there is already a statement:
Private Sub Worksheet_Change(ByVal Target As Range
followed by End Sub (nothing between).

I tried deleting those two statements but then data entered in the sheet
was not correct.

I do not know what wording to change to get it to work.

Orf

Bob Phillips wrote:

Hi Orf,

VBA will do it

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:H10")) Is Nothing Then
With Target
.Value = Format(Date, "dd mmm yyyy")
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

This is worksheet event code, so right-click the sheet tab, select View
Code, and paste the code in.








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Automatic Dates

Bob, the codes that were present before I added your code a


Private Sub Worksheet_Change(ByVal Target As Range)

End Sub


Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub


I then added your code:

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:H10")) Is Nothing Then
With Target
.Value = Format(Date, "dd mmm yyyy")
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub



and that is when an error message came up.

Orf



Bob Phillips wrote:

Orf,

Your reasoning is correct.

Post the 2 change event codes and I will try and merge them for you.




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Automatic Dates

Hey Orf,

That is so easy.

The other two do nothing, so just get rid of them.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Orf Bartrop" wrote in message
...
Bob, the codes that were present before I added your code a


Private Sub Worksheet_Change(ByVal Target As Range)

End Sub


Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub




I then added your code:

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:H10")) Is Nothing Then
With Target
.Value = Format(Date, "dd mmm yyyy")
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub



and that is when an error message came up.

Orf



Bob Phillips wrote:

Orf,

Your reasoning is correct.

Post the 2 change event codes and I will try and merge them for you.






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
using automatic dates in cells shereea_1 Excel Worksheet Functions 3 January 7th 09 09:11 PM
automatic dates flame New Users to Excel 1 August 31st 07 10:31 AM
How do I switch off automatic formatting (e.g. dates)? Coen Excel Discussion (Misc queries) 8 July 13th 06 08:08 AM
stop automatic increment of dates Susan C. Excel Discussion (Misc queries) 2 September 21st 05 05:57 PM
Help with automatic dates foxx60 New Users to Excel 1 August 19th 05 06:01 PM


All times are GMT +1. The time now is 10:59 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"