View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Simple code makes Excel 2007 crash

Hi,

The OP wanted to check the full column so 65536 doesn't work in Excel 2007

Mike

"Ivyleaf" wrote:

On Apr 7, 5:28 pm, "Ron de Bruin" wrote:
Hi Mathieu

No problem here
Do you have the same problem in a new workbook

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm

"Mathieu" schreef in . ..



Hello All,


I use this code to check if a value changes in a specific column and update
the adjacent cell (one to the right) with today's date.
However, it makes Excel 2007 crash.


Any advice?


Private Sub Worksheet_Change(ByVal Target As Range)
If ((ActiveCell.Column = 6) And (ActiveCell.Row 5)) Then
ActiveCell.Offset(0, 1).Value = Str(Date)
End If
End Sub


Thanks!
Mathieu- Hide quoted text -


- Show quoted text -


Hi Mathieu,

I can't see anything wrong with that either, but I would suggest using
the 'Target' range rather than Activecell to test what has changed.
They should both always be the same, but there is a chance that they
won't be... for example if another macro changes a value in column F,
you would presumably still want to catch it but the active cell could
be anything. I'd suggest:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target.Cells(1), _
Range("F6:F65536")) Is Nothing Then
Target.Cells(1).Offset(0, 1).Value = Str(Date)
End If
End Sub

Cheers,
Ivan.