Recalculate on condition

D

DavidObeid

Is there a way to make excel recalculate a spreadsheet if a given
condition is met/not met?

EG, =if(A1 ><1,"",recalculate)
 
E

Excelenator

I assume your worksheet is set to manual recalculation and that you
meant that A1<>1 (Not equal to) below?

If so you can place this code in the Worksheet_Change event


Code:
--------------------
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("A1").Value <> 1 Then
Calculate
End If
End Sub
--------------------


Hope this helps!
:cool:
Is there a way to make excel recalculate a spreadsheet if a given
condition is met/not met?

EG, =if(A1 ><1,"",recalculate)
 
D

DavidObeid

Thanks Excelenator,

I actually meant >= 1

The spreadsheet automatically calculates, but some values are user
defined, some the result of formulae and some the result of a randomly
generated number.

I don't know VBA, so can you give me idiot proof instructions as to how
to implement the solution?
 
E

Excelenator

Sure thing.


- Copy the code below
- Right click on the sheet tab of the sheet containing your data
- Select "View Code"
- This will take you to the VBE (Visual Basic Editor)
- You should see two drop down boxes towards the top of the screen
- The one on the left says "General". Drop down and selec
"Worksheet"
- Highlight the code that gets populated and right click and selec
Paste to paste in the code below.
- Return to your worksheet


Now anytime the value of Cell A1 is >= 1 the worksheet wil
recalculate.


Code
-------------------
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("A1").Value >= 1 Then
Calculate
End If
End Su
-------------------
 
Top