Repeating an equations operations on result

FranklyPineapple

New Member
Joined
Jun 1, 2016
Messages
2
Hi,

I have a series of IF functions, and if they all 4 of them return negatively I want it to run again. The first IF is based of a RANDBETWEEN function so it would give a different result, not resulting in a loop.

I have tried code such as

Code:
Sub Worksheet_Activate()
    If (Worksheets("Sheet1").Cells(2, 23)) = 1 Then
         ActiveSheet.EnableCalculation = False
         ActiveSheet.EnableCalculation = True
       Else
    End If
End Sub

and

Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    If (Worksheets("Sheet1").Cells(2, 23)) = 1 Then
         ActiveSheet.EnableCalculation = False
         ActiveSheet.EnableCalculation = True
       Else
    End If
End Sub

The first of which works, but only if I switch sheets then come back to the original sheet, it does not run automatically as I would like it to.


Any help would be welcome, thanks.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Welcome to the board.

The first of which works, but only if I switch sheets then come back to the original sheet, it does not run automatically as I would like it to.
It runs when the procedure name suggests: when the worksheet is activated. When would you otherwise want it to run?

The Change event will run in response to manual changes or cell changes via code, not changes as a result of calculation.

If the worksheet recalculates as a result of volatile formulas, then perhaps you should check after enabling calculation to see if it needs to be calculated again.
 
Last edited:
Upvote 0
Could you please explain what you mean by this?
What is the point of the worksheet activate code? Why does it test W23? Does enabling calculation cause W23 to recalculate? If so, is it certain that it will W2's value will be acceptable? If not, what could you do?
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top