473,503 Members | 7,214 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I get this Loop to stop

31 New Member
I have written this to clear cells coloured 56 in the target row from columns A to L when a Message box is OK'd. But how do I stop it from carrying on and on?
Expand|Select|Wrap|Line Numbers
  1. Dim Rw As String
  2. Rw = Target.Row
  3. Dim Ar As String
  4. Ar = "A" & Rw & ":" & "L" & Rw
  5. Dim Rg As Range
  6. Set Rg = Range(Ar)
  7.  
  8. For Each cl In Rg
  9.  
  10.         With cl
  11.             If .Offset(0, 0).Interior.ColorIndex = 56 Then
  12.                 .ClearContents
  13.             End If
  14.         End With
  15.  
  16.     Next cl
  17.  
  18. End Sub
Thanks.
Apr 12 '12 #1
1 1432
philqw78
31 New Member
Sorry again. Figured it out. I am not having to escape the loop. The code keeps going round because the worksheet change events are fired.

Expand|Select|Wrap|Line Numbers
  1. Application.EnableEvents=False
  2. 'then later 
  3. ....True 
cures it
Apr 12 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

12
1689
by: Steve | last post by:
Hi, I'm getting some output by running a command using os.popen. I need to parse the output and transform it in some sense so that it's 'DB compatible', (i.e I need to store the output in a...
8
3641
by: ben | last post by:
i have a bit of code, that works absolutely fine as is, but seems over complicated/long winded. is there anyway to shorten/simplify it? the code is below. description of it: it's like strcpy in...
3
2521
by: Douglas | last post by:
Hi, In the loop for(i=0; i< h+1; i++); if h=10 say, then is h+1 evaluated every time or, between iterations, does the for loop remember that the condition i<11 is being applied? I'm guessing...
25
3757
by: jwrweatherley | last post by:
I'm pretty new to python, but am very happy with it. As well as using it at work I've been using it to solve various puzzles on the Project Euler site - http://projecteuler.net. So far it has not...
2
4331
by: mika_ella258 | last post by:
the output should be like this Loop Program -------------------- enter 1st integer: enter 2nd integer: enter 3rd integer: enter 4th integer: enter 5th integer:
2
1420
by: thaiZilla | last post by:
userlist=`who | cut -d " " -f1` linetotal=`cat $userlist| wc -l` linenumber='1' while do username=`somestuff` put that in for now basically i want the username variable to be equal to the...
2
201
by: dp_pearce | last post by:
I have some code that takes data from an Access database and processes it into text files for another application. At the moment, I am using a number of loops that are pretty slow. I am not a...
3
1459
Thekid
by: Thekid | last post by:
I need help writing a loop for this. image = ImageGrab.grab((0,0,800,800)) box = (100,100,400,400) im = image.crop(box) im1 = im.save("screen.jpg") # at this point I need to rotate the image...
1
1505
by: Kristoffer | last post by:
I can't comprehend that this loop isnt working in practise as in my head it makes perfect theoretical sense while(fscanf(input, "%c", &c)==1) { i = 0; while(c!=';') { printf("%c",...
0
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7291
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7357
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7012
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.