Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 69
Default Looping till condition is satisfied?

I have this macro's code:

Dim SCell As Integer
Do Until SCell.Value = 1
If SCell.Value < 1 Then

Range("J24").Select
Calculate
End If
Loop

Where SCell has a formula like this: "if (A2<A3,1,0)" and A2 has a
random number while A3 is a fixed value. I want the macro once clicked
to keep changing A2 till SCell formula is 1. So the loop could run 5
times or 500 times.

Is there something wrong in the code above?

Thanks,
Jo

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JNW JNW is offline
external usenet poster
 
Posts: 480
Default Looping till condition is satisfied?

Your code isn't actually changing cell A2. all it is doing is recalculating
the sheet. Is this what you wanted to do? Is there something else that is
changing A2?
--
JNW


"Jo" wrote:

I have this macro's code:

Dim SCell As Integer
Do Until SCell.Value = 1
If SCell.Value < 1 Then

Range("J24").Select
Calculate
End If
Loop

Where SCell has a formula like this: "if (A2<A3,1,0)" and A2 has a
random number while A3 is a fixed value. I want the macro once clicked
to keep changing A2 till SCell formula is 1. So the loop could run 5
times or 500 times.

Is there something wrong in the code above?

Thanks,
Jo


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 69
Default Looping till condition is satisfied?

On Oct 4, 11:17 am, JNW wrote:
Your code isn't actually changing cell A2. all it is doing is recalculating
the sheet. Is this what you wanted to do? Is there something else that is
changing A2?
--
JNW



"Jo" wrote:
I have this macro's code:


Dim SCell As Integer
Do Until SCell.Value = 1
If SCell.Value < 1 Then


Range("J24").Select
Calculate
End If
Loop


Where SCell has a formula like this: "if (A2<A3,1,0)" and A2 has a
random number while A3 is a fixed value. I want the macro once clicked
to keep changing A2 till SCell formula is 1. So the loop could run 5
times or 500 times.


Is there something wrong in the code above?


Thanks,
Jo- Hide quoted text -


- Show quoted text -


When it recalculates the sheet, the random number does change and so
SCell does check the condition to see if satisfied or not. The macro
has to stop once SCell is satisfied.
That is all actually.

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 227
Default Looping till condition is satisfied?

On Oct 4, 11:28 am, Jo wrote:
On Oct 4, 11:17 am, JNW wrote:




You Dim an Integer variable SCell, then do nothing with it. Thus it
is always zero.

If you have a cell named "SCell" you can write something like this:

Range("J24").Select

Do Until Range("SCell").Value = 1
Calculate
Loop


Your code isn't actually changing cell A2. all it is doing is recalculating
the sheet. Is this what you wanted to do? Is there something else that is
changing A2?
--
JNW


"Jo" wrote:
I have this macro's code:


Dim SCell As Integer
Do Until SCell.Value = 1
If SCell.Value < 1 Then


Range("J24").Select
Calculate
End If
Loop


Where SCell has a formula like this: "if (A2<A3,1,0)" and A2 has a
random number while A3 is a fixed value. I want the macro once clicked
to keep changing A2 till SCell formula is 1. So the loop could run 5
times or 500 times.


Is there something wrong in the code above?


Thanks,
Jo- Hide quoted text -


- Show quoted text -


When it recalculates the sheet, the random number does change and so
SCell does check the condition to see if satisfied or not. The macro
has to stop once SCell is satisfied.
That is all actually.- Hide quoted text -

- Show quoted text -



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
Looping till value is 1? Jo[_2_] Excel Discussion (Misc queries) 2 October 3rd 07 09:14 PM
How to change the value of a cell when a condition is satisfied, but not otherwise? benzi_k_ahamed Excel Discussion (Misc queries) 0 January 11th 06 11:31 AM
SUM C IF B=Cap... Till Next B=Cap... cradino Excel Worksheet Functions 6 October 13th 05 12:45 AM
SUM C IF B=Cap...TILL NEXT B=Cap... cradino Excel Worksheet Functions 1 October 10th 05 01:05 AM
Deletion of rows where a value is satisfied Larry Wallis Excel Worksheet Functions 1 February 22nd 05 12:41 PM


All times are GMT +1. The time now is 05:08 PM.

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"