kRiShNa_96
New Member
- Joined
- Feb 24, 2017
- Messages
- 2
Hi, I'm new to VBA but for a project I'm working on, the calculations require a series of formulas which have to be manually carried out such as several goal seeks.
So far I have been able to enable them with a series of macros with a worksheet selection change such as below.
Also the macro carries out the goal seek required. This works fine however the problem with the worksheet selection change is that I need to be clicked on the worksheet containing the code in order for the macro to be initiated, however I want the macro to run as soon as the current value is changed.
I have tried a worksheet_change event and it worked, but as the range is for a formula I think I need a worksheet_calculate formula so that it runs whenever the formula value changes. In all of my cases if the value is non zero, I need the relevant macros to run. Could someone help me come up with relevant code for the worksheets?
Kind Regards
So far I have been able to enable them with a series of macros with a worksheet selection change such as below.
Also the macro carries out the goal seek required. This works fine however the problem with the worksheet selection change is that I need to be clicked on the worksheet containing the code in order for the macro to be initiated, however I want the macro to run as soon as the current value is changed.
I have tried a worksheet_change event and it worked, but as the range is for a formula I think I need a worksheet_calculate formula so that it runs whenever the formula value changes. In all of my cases if the value is non zero, I need the relevant macros to run. Could someone help me come up with relevant code for the worksheets?
Kind Regards
Rich (BB code):
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Rich (BB code):
Dim found As Boolean
found = False
For Each cell In Range("AH106", "AH107").Cells
If cell.Value = "X" Then
found = True
End If
Next
If found = True Then
Call GoalSeek_T113
Else
'Call GoalSeek_T113'
End If
End Sub