ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Cell change event causing EXCEL to crash (https://www.excelbanter.com/excel-worksheet-functions/215765-cell-change-event-causing-excel-crash.html)

ashish

Cell change event causing EXCEL to crash
 
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


Mike H

Cell change event causing EXCEL to crash
 
Hi,

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

Mike

"Ashish" wrote:

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


Dave Peterson

Cell change event causing EXCEL to crash
 
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).



Ashish wrote:

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


--

Dave Peterson

ashish

Cell change event causing EXCEL to crash
 
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



"Mike H" wrote:

Hi,

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

Mike

"Ashish" wrote:

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



All times are GMT +1. The time now is 10:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com