Hi,
I am trying to write a script for a conditional goal seek. If the value sought in cell B1 is less than 0, I would like the message box to return language that says, "Growth from A may not exceed growth from B". If the value in B1 is greater than 0, I would like the message box to return language that says, "Optimal Growth - XX.XX%"
My issue with the below is that I have to run the macro twice in order to get my first language that growth A may not exceed growth B. I only want to have to run the macro once.
Any help is much appreciated.
Sub Optgrwth()
Dim SPGrowth As Integer, result As String
SPGrowth = Range("B1").Value
Range("C1").GoalSeek Goal:=0, ChangingCell:=Range("B1")
For Each EQ In ActiveSheet.Range("C1")
If SPGrowth < 0 Then
MsgBox "Growth from A may not exceed growth from B"
ElseIf EQ.Value = 0 Then
MsgBox "Optimal Stock Growth - " & (Format(Range("B1"), "#.####%"))
Else
End If
Next EQ
End Sub
I am trying to write a script for a conditional goal seek. If the value sought in cell B1 is less than 0, I would like the message box to return language that says, "Growth from A may not exceed growth from B". If the value in B1 is greater than 0, I would like the message box to return language that says, "Optimal Growth - XX.XX%"
My issue with the below is that I have to run the macro twice in order to get my first language that growth A may not exceed growth B. I only want to have to run the macro once.
Any help is much appreciated.
Sub Optgrwth()
Dim SPGrowth As Integer, result As String
SPGrowth = Range("B1").Value
Range("C1").GoalSeek Goal:=0, ChangingCell:=Range("B1")
For Each EQ In ActiveSheet.Range("C1")
If SPGrowth < 0 Then
MsgBox "Growth from A may not exceed growth from B"
ElseIf EQ.Value = 0 Then
MsgBox "Optimal Stock Growth - " & (Format(Range("B1"), "#.####%"))
Else
End If
Next EQ
End Sub