Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Simple code makes Excel 2007 crash

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Simple code makes Excel 2007 crash

Hi Mathieu

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

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Mathieu" schreef in bericht ...
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Simple code makes Excel 2007 crash

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.
  #4   Report Post  
Posted to microsoft.public.excel.programming
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.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Simple code makes Excel 2007 crash

Did you put an entry in Column 6 with Row 5 when you tested it? I ask because that code crashes for me also and I think the reason is the unchained set of Worksheet_Change event calls that the first entry initiates.

Rick


"Ron de Bruin" wrote in message ...
Hi Mathieu

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

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Mathieu" schreef in bericht ...
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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Simple code makes Excel 2007 crash

Your post just made me realized that this was a rookie-mistake!

When you change the value of the adjacent cell using offset, this doesn't
change which cell is activated, so the 'IF' condition is still true, which
starts a recurring loop.

Changed the code to this crappy version:

If ActiveCell.Column = 6 And ActiveCell.Row 5 Then
ActiveCell.Offset(0, 1).Activate
ActiveCell.Value = Date
End If

Thanks All for your help!
Mathieu


"Rick Rothstein (MVP - VB)" wrote in
message ...
Did you put an entry in Column 6 with Row 5 when you tested it? I ask
because that code crashes for me also and I think the reason is the
unchained set of Worksheet_Change event calls that the first entry
initiates.

Rick


"Ron de Bruin" wrote in message
...
Hi Mathieu

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

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Mathieu" schreef in bericht
...
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


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Simple code makes Excel 2007 crash

On Apr 7, 3:14*pm, "Mathieu" wrote:
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


Hi,

Did this problem lead to damage of your excel file? If so, I think you
can try a utility called Advanced Excel Repair to repair your Excel
xls file. It works rather well for my corrupt Excel xls files. Its web
address is http://www.datanumen.com/aer/

Hope this helps.

Alan
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
Application makes VBE crash. How do I troubleshoot? Bdra Excel Programming 4 January 10th 08 08:27 AM
this code makes excel crash zz Excel Programming 0 December 22nd 06 11:14 PM
XLA makes XL2003 crash Soren[_2_] Excel Programming 3 September 27th 05 01:40 PM
XLA makes XL2003 crash Soren[_2_] Excel Programming 0 September 26th 05 09:31 AM
HELP - simple VBA property causes Excel to crash No Name Excel Programming 0 October 23rd 03 08:38 PM


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