Cell change event causing EXCEL to crash

  • Thread starter Thread starter Ashish
  • Start date Start date
A

Ashish

Hi,

I am writing the following piece of code to change a cell color when its
content is changed:

*******************************************************
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Me.Range("$E$25")) Is Nothing Then
If ThisWorkbook.Worksheets(6).Cells(25, 5) > 0 Then
ThisWorkbook.Worksheets(6).Cells(25, 5).Interior.Pattern = xlGray16
End If
End Sub
*******************************************************

However, my excel window crashes and i get the following message "Microsoft
Excel has encoutered a problem and needs to close..."
Can anyone tell me why this should happen?

Appreciate an urgent response.

Thanks and regards,
Ashish
 
Hi,

Your sub is missing an End If but that wouldn't cause Excel to crash. I
would try restarting your PC.

Mike
 
I'd try changing printers (or printer drivers).

Lots of crashes in excel turn out to be caused by printer drivers.

And since you're playing with a color (something displayed on the screen), excel
uses the printer driver to determine how it should look on the screen and when
printed (WYSIWYG stuff).
 
Hi,

The sub is as follows:

*******************************************************
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Me.Range("$E$25")) Is Nothing Then
ThisWorkbook.Worksheets(6).Cells(25, 5).Interior.Pattern = xlGray16
End If
End Sub
*******************************************************

Please let me know why should EXCEL crash when i invoke this SUBROUTINE
(MACRO). BTW, restarting the PC does not seem to help.

Thanks and regards,
Ashish
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top