LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 698
Default Code does a continous loop

Hello Excel users and experts,
Excel 2002

In the first If statement when i = 11 it statement works fine as long as I
have ' Target.Value = "" out of the code.
If I remove the ' from Target.Value = "" and run the macro it goes ino a
continous loop with the message box displayed. I have to crash out with
Ctrl -Alt - Del. Am I looking right past something?

Thanks for any help you can offer.
Regards,
Howard

Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Integer

i = Application.WorksheetFunction. _
CountA(Worksheets("Sales Order") _
.Range("A17:A27"))

If i = 11 Then
MsgBox "The sales order is full." & vbCr _
& vbCr & "Process a new order."
' Target.Value = ""
Application.DisplayAlerts = False
Exit Sub
End If

If Target.Column < 1 Then Exit Sub
If Target.Value = "" Then Exit Sub
Target.Resize(1, 4).Select
If MsgBox(prompt:=" Post this selection to Order Sheet?", _
Buttons:=vbYesNo, _
Title:="Poster") = vbYes Then
Target.Resize(1, 4).Copy _
Sheets("Sales Order").Range("A27") _
.End(xlUp).Offset(1, 0)
Target.Value = ""
Application.DisplayAlerts = False
ElseIf vbNo Then
Target.Value = ""
Application.DisplayAlerts = False
End If
Target.Select

End Sub


 
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
Loop for VBA code? paulinoluciano Excel Worksheet Functions 5 December 28th 05 01:30 PM
How to Loop some code Phil Osman Excel Discussion (Misc queries) 2 August 19th 05 11:14 AM
How to get my code to loop Dominique Feteau[_2_] Excel Programming 5 December 17th 04 01:35 PM
Help with loop code... gaba Excel Programming 1 October 20th 04 01:37 PM
VBE code in a loop loloflores Excel Programming 0 April 30th 04 12:28 PM


All times are GMT +1. The time now is 08:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"