简体   繁体   中英

ExcelVba Goal Seek for dynamic goal

I set up a goal seek using macro to calculate break even of selling price by setting target profit as $1000. I am now wondering if i can change my vba coding in a way that if i change Set target profit (Goal value) from 1000 to say 200 (or any number), it will update break even price.

Set Cell E12 Changing Cell B5 to value is 1000 c12 (Which i am entering manually in goal seek tab)

Sub FindBreakEven()
'
' FindBreakEven Macro
'

    Range("E12").GoalSeek Goal:=1000, ChangingCell:=Range("B5")
End Sub

Try this:

Sub FindBreakEven()
'
' FindBreakEven Macro
'

    Range("E12").GoalSeek Goal:=Range("B6"), ChangingCell:=Range("B5")
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM