#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Crashing!!!

I have this code sat in sheet 5 ("Risk By Functions") and the first bit was
working fine until I put in a loop and message box to make sure people enter
a reason why the controls aren't working. Now it still works but when I try
and take the information out of the cells it causes my spreadsheet to crash.
The code is as below. Would anyone be able to help me with this?

Private Sub worksheet_change(ByVal Target As Range)
Application.ScreenUpdating = False
Do Until Target.Offset(0, 1) < ""
If Target.Count 1 Then Exit Sub
If Not Intersect(Target, Range("P2:P296")) Is Nothing Then
If Target.Value = "No" Then
Response = InputBox("Why are the controls not working?")
Target.Offset(0, 1).Value = Response
If Target.Value = "No" And Response = "" Then
MsgBox "You have not entered a reason why", vbCritical
End If
End If
End If
Loop
If Target.Column = 23 Then
If Target < Cells(Target.Row, 22) Then

ReasonWhy = InputBox("Enter Reason date was Pushed back")
Cells(Target.Row, 24) = ReasonWhy

End If

End If
Application.ScreenUpdating = True
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Crashing!!!

Try placing your loop inside the If statement like this:

If Target.Count 1 Then Exit Sub
If Not Intersect(Target, Range("P2:P296")) Is Nothing Then
If Target.Value = "No" Then
Do Until Target.Offset(0, 1) < ""
Response = InputBox("Why are the controls not working?")
Target.Offset(0, 1).Value = Response
If Target.Value = "No" And Response = "" Then
MsgBox "You have not entered a reason why", vbCritical
End If
Loop
End If
End If



"Pasty" wrote:

I have this code sat in sheet 5 ("Risk By Functions") and the first bit was
working fine until I put in a loop and message box to make sure people enter
a reason why the controls aren't working. Now it still works but when I try
and take the information out of the cells it causes my spreadsheet to crash.
The code is as below. Would anyone be able to help me with this?

Private Sub worksheet_change(ByVal Target As Range)
Application.ScreenUpdating = False
Do Until Target.Offset(0, 1) < ""
If Target.Count 1 Then Exit Sub
If Not Intersect(Target, Range("P2:P296")) Is Nothing Then
If Target.Value = "No" Then
Response = InputBox("Why are the controls not working?")
Target.Offset(0, 1).Value = Response
If Target.Value = "No" And Response = "" Then
MsgBox "You have not entered a reason why", vbCritical
End If
End If
End If
Loop
If Target.Column = 23 Then
If Target < Cells(Target.Row, 22) Then

ReasonWhy = InputBox("Enter Reason date was Pushed back")
Cells(Target.Row, 24) = ReasonWhy

End If

End If
Application.ScreenUpdating = True
End Sub


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
excel Crashing SJMP Setting up and Configuration of Excel 3 March 6th 09 12:27 PM
Why Is This Crashing Ben Excel Programming 1 November 3rd 05 05:56 AM
vb exe crashing kasi Excel Programming 1 October 15th 05 03:33 AM
Is this crashing for you ? Alex T Excel Programming 6 September 5th 04 05:17 PM
vba crashing scottwilsonx[_15_] Excel Programming 2 August 6th 04 01:16 PM


All times are GMT +1. The time now is 02:29 AM.

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"