Thomas Kuriakose
Active Member
Respected Sirs,
We have a requirement to use goal seek using vba to arrive at the percent change based on input value and final value. Kindly find attached a sample sheet where the details are entered.
Cell E4 is the set cell
Cell C5 is the changing cell
When we enter the value in the input box as % or decimal value, it is not correctly calculating. How can we input a value of 0.05, 0.10 etc. or 5%, 10% etc. in the input box to get the result..
The code entered is as follows -
Thank you very much for your support always,
with regards,
thomas
We have a requirement to use goal seek using vba to arrive at the percent change based on input value and final value. Kindly find attached a sample sheet where the details are entered.
Cell E4 is the set cell
Cell C5 is the changing cell
When we enter the value in the input box as % or decimal value, it is not correctly calculating. How can we input a value of 0.05, 0.10 etc. or 5%, 10% etc. in the input box to get the result..
The code entered is as follows -
Code:
Option Explicit
Sub GoalSeekVBA()
Dim Target As Long
On Error GoTo Errorhandler
Target = InputBox("Enter the required value", "Enter Value")
Worksheets("Sheet1").Activate
With ActiveSheet
.Range("E4").GoalSeek Goal:=Target, ChangingCell:=Range("C5")
End With
Exit Sub
Errorhandler:
MsgBox ("Sorry, value is not valid.")
End Sub
Thank you very much for your support always,
with regards,
thomas