ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Recalculate on condition (https://www.excelbanter.com/excel-discussion-misc-queries/102597-recalculate-condition.html)

DavidObeid

Recalculate on condition
 

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

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


--
DavidObeid


------------------------------------------------------------------------
DavidObeid's Profile: http://www.excelforum.com/member.php...fo&userid=2238
View this thread: http://www.excelforum.com/showthread...hreadid=567317


Excelenator

Recalculate on condition
 

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:

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

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



--
Excelenator


------------------------------------------------------------------------
Excelenator's Profile: http://www.excelforum.com/member.php...o&userid=36768
View this thread: http://www.excelforum.com/showthread...hreadid=567317


DavidObeid

Recalculate on condition
 

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?


--
DavidObeid


------------------------------------------------------------------------
DavidObeid's Profile: http://www.excelforum.com/member.php...fo&userid=2238
View this thread: http://www.excelforum.com/showthread...hreadid=567317


Excelenator

Recalculate on condition
 

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 select
"Worksheet"
- Highlight the code that gets populated and right click and select
Paste to paste in the code below.
- Return to your worksheet


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


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


--
Excelenator


------------------------------------------------------------------------
Excelenator's Profile: http://www.excelforum.com/member.php...o&userid=36768
View this thread: http://www.excelforum.com/showthread...hreadid=567317



All times are GMT +1. The time now is 10:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com