Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
mark
 
Posts: n/a
Default Excel 2003 Inserting current date

I wish to create a spreadsheet that whenever data is entered in a
row/column, the actual date is entered automatically in a date column. I do
not want the date to be overridden.
  #2   Report Post  
Gord Dibben
 
Posts: n/a
Default

Mark

Right-click your sheet tab and "View Code".

Copy/paste this event code in that sheet module.

Enter anything in any cell in column A and B will get a static date.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'Col B time will not change if data in Col A is edited
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 Then
n = Target.Row
If Excel.Range("A" & n).Value < "" _
And Excel.Range("B" & n).Value = "" Then
Excel.Range("B" & n).Value = Format(Now, "dd mmm yyyy")
End If
End If
enditall:
Application.EnableEvents = True
End Sub


Gord Dibben Excel MVP

On Tue, 8 Feb 2005 11:05:03 -0800, "mark"
wrote:

I wish to create a spreadsheet that whenever data is entered in a
row/column, the actual date is entered automatically in a date column. I do
not want the date to be overridden.


  #3   Report Post  
mark
 
Posts: n/a
Default

Gord

Many Thanks

How can I now protect the range of cells with date in it? When I try to
protect the column the formula disappears.

Mark

"Gord Dibben" wrote:

Mark

Right-click your sheet tab and "View Code".

Copy/paste this event code in that sheet module.

Enter anything in any cell in column A and B will get a static date.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'Col B time will not change if data in Col A is edited
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 Then
n = Target.Row
If Excel.Range("A" & n).Value < "" _
And Excel.Range("B" & n).Value = "" Then
Excel.Range("B" & n).Value = Format(Now, "dd mmm yyyy")
End If
End If
enditall:
Application.EnableEvents = True
End Sub


Gord Dibben Excel MVP

On Tue, 8 Feb 2005 11:05:03 -0800, "mark"
wrote:

I wish to create a spreadsheet that whenever data is entered in a
row/column, the actual date is entered automatically in a date column. I do
not want the date to be overridden.



  #4   Report Post  
Gord Dibben
 
Posts: n/a
Default

Mark

One more step........

Copy/paste the code below into the ThisWorkbook module.

Right-click on the Excel logo left of "File" on menu bar or on logo at top
left corner of Window if not maximized.

Select "View Code" and paste into that module.

Private Sub Workbook_Open()
Dim sh As Worksheet
Application.ScreenUpdating = False
Sheets("Sheet1").Protect "justme", , , userinterfaceonly:=True
Application.ScreenUpdating = True
End Sub

"Sheet1" is the name of your sheet. Adjust to suit.

What this code does is allow the code to run on a protected sheet.

Unlock column A so's data can be entered. Lock Column B so's the dates cannot
be deleted.

Save the workbook then re-open.


Gord

On Wed, 9 Feb 2005 01:37:04 -0800, "mark"
wrote:

Gord

Many Thanks

How can I now protect the range of cells with date in it? When I try to
protect the column the formula disappears.

Mark

"Gord Dibben" wrote:

Mark

Right-click your sheet tab and "View Code".

Copy/paste this event code in that sheet module.

Enter anything in any cell in column A and B will get a static date.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'Col B time will not change if data in Col A is edited
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 Then
n = Target.Row
If Excel.Range("A" & n).Value < "" _
And Excel.Range("B" & n).Value = "" Then
Excel.Range("B" & n).Value = Format(Now, "dd mmm yyyy")
End If
End If
enditall:
Application.EnableEvents = True
End Sub


Gord Dibben Excel MVP

On Tue, 8 Feb 2005 11:05:03 -0800, "mark"
wrote:

I wish to create a spreadsheet that whenever data is entered in a
row/column, the actual date is entered automatically in a date column. I do
not want the date to be overridden.




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
Excel 2003 FAILS, but Excel 2000 SUCCEEDS ??? Richard Excel Discussion (Misc queries) 2 May 13th 23 11:46 AM
Excel 2003 is changing my date formats nbalch Excel Worksheet Functions 4 January 26th 05 07:01 PM
Inserting the date that an excel sheet is saved into a cell sharock Excel Discussion (Misc queries) 2 January 6th 05 07:07 PM
In Excel 2003, entering date without slashes, the date is incorre. sj Excel Discussion (Misc queries) 6 January 6th 05 03:07 PM
Excel 2003 "File Open": how keep folders at top with sort by Date. Aging Analyst Excel Discussion (Misc queries) 1 December 3rd 04 03:26 AM


All times are GMT +1. The time now is 01:34 AM.

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

About Us

"It's about Microsoft Excel"