Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Automaticaly Enter Date in selected Cell

All,

I am trying to perfect a macro that will, when the word "Reporting" is put
in cell D2 enter a date stamp into cell I2.

I have got this far after some experimenting but it keeps coming up with an
error message. The macro I have so far is,

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count 1 Then Exit Sub
If Not Intersect(Range("D2:D100"), .Cells) Is Nothing Then
Application.EnableEvents = False
If Target = "Reporting" Then
With .Offset(0, 5)
.NumberFormat = "dd/mm/yyyy"
.Value = Now
End With
Application.EnableEvents = True
End If
End With
End Sub

Any Suggestions?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,624
Default Automaticaly Enter Date in selected Cell

You were missing an End If. Try

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count 1 Then Exit Sub
If Not Intersect(Range("D2:D100"), .Cells) Is Nothing Then
If Target = "Reporting" Then
On Error Resume Next
Application.EnableEvents = False
With .Offset(0, 5)
.NumberFormat = "dd/mm/yyyy"
.Value = Now
End With
Application.EnableEvents = True
End If
End If
End With
End Sub

In article ,
Ceptor54 wrote:

All,

I am trying to perfect a macro that will, when the word "Reporting" is put
in cell D2 enter a date stamp into cell I2.

I have got this far after some experimenting but it keeps coming up with an
error message. The macro I have so far is,

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count 1 Then Exit Sub
If Not Intersect(Range("D2:D100"), .Cells) Is Nothing Then
Application.EnableEvents = False
If Target = "Reporting" Then
With .Offset(0, 5)
.NumberFormat = "dd/mm/yyyy"
.Value = Now
End With
Application.EnableEvents = True
End If
End With
End Sub

Any Suggestions?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Automaticaly Enter Date in selected Cell

Worked perfectly thanks a lot!!!

"JE McGimpsey" wrote:

You were missing an End If. Try

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count 1 Then Exit Sub
If Not Intersect(Range("D2:D100"), .Cells) Is Nothing Then
If Target = "Reporting" Then
On Error Resume Next
Application.EnableEvents = False
With .Offset(0, 5)
.NumberFormat = "dd/mm/yyyy"
.Value = Now
End With
Application.EnableEvents = True
End If
End If
End With
End Sub

In article ,
Ceptor54 wrote:

All,

I am trying to perfect a macro that will, when the word "Reporting" is put
in cell D2 enter a date stamp into cell I2.

I have got this far after some experimenting but it keeps coming up with an
error message. The macro I have so far is,

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count 1 Then Exit Sub
If Not Intersect(Range("D2:D100"), .Cells) Is Nothing Then
Application.EnableEvents = False
If Target = "Reporting" Then
With .Offset(0, 5)
.NumberFormat = "dd/mm/yyyy"
.Value = Now
End With
Application.EnableEvents = True
End If
End With
End Sub

Any Suggestions?


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
can excel automatically enter the date data in a cell was entered mg_sv_r Excel Worksheet Functions 4 September 5th 08 11:09 AM
to enter today's date if a cell is blank Lynn Hanna Excel Worksheet Functions 1 July 26th 06 01:06 PM
run a macro in a locked cell Ray Excel Discussion (Misc queries) 8 January 10th 06 12:02 AM
Possible Lookup Table Karen Excel Worksheet Functions 5 June 8th 05 09:43 PM
Changing Cell formats to date fields automatically PCLIVE Excel Worksheet Functions 3 April 12th 05 10:34 PM


All times are GMT +1. The time now is 08:19 PM.

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"