ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   vba goal seek 2 (https://www.excelbanter.com/excel-programming/331533-vba-goal-seek-2-a.html)

csw78[_3_]

vba goal seek 2
 

Hi, my intent is to perform goal seek for each row (_twice_) from row 19
to 27 as follow. Somehow the goal seek below row 19 cannot be
"activated" unless the value in the "most upper right cell", in this
case Range("BA19") is targeted. I don't quite see the logic. I was
thinking about using "for each ... in ..." but didn't know how to set
the group as rows?

Method 1:
For i = 19 To 27
Cells(i, "AE").GoalSeek Goal:=Cells(i, "AD"), ChangingCell:=Cells(i,
"AF")
Cells(i, "AZ").GoalSeek Goal:=Cells(i, "O"), ChangingCell:=Cells(i,
"BA")
Next i

Method 1: If row 19 is targeted, then goal seek from 19 to 27 will be
activated. However, if row below 19 is targeted, no goal seek because
the count has to start from row 19?


Method 2:
Range("AE19").GoalSeek Goal:=Range("AD19"),
ChangingCell:=Range("AF19")
.......
Range("AE27").GoalSeek Goal:=Range("AD27"),
ChangingCell:=Range("AF27")

Range("AZ19").GoalSeek Goal:=Range("O19"), ChangingCell:=Range("BA19")
......
Range("AZ27").GoalSeek Goal:=Range("O27"), ChangingCell:=Range("BA27")

Method 2: Goal seek only activates for "AF", no goal seek for "BA"
because row 19 through 27 has already been passed once on
worksheet_calculate()? I guess it's a looping problem.

Thanks for your input.


--
csw78
------------------------------------------------------------------------
csw78's Profile: http://www.excelforum.com/member.php...o&userid=23008
View this thread: http://www.excelforum.com/showthread...hreadid=378345


csw78[_4_]

vba goal seek 2
 

Please ignore the post. The following seems to work fine, didn't know
why it wasn't working yesterday. I might have missed a couple of inputs
within the row or the goal seek just wasn't converging. Thanks all!

Method 1:
For i = 19 To 27
Cells(i, "AE").GoalSeek Goal:=Cells(i, "AD"), ChangingCell:=Cells(i,
"AF")
Cells(i, "AZ").GoalSeek Goal:=Cells(i, "O"), ChangingCell:=Cells(i,
"BA")
Next i


--
csw78
------------------------------------------------------------------------
csw78's Profile: http://www.excelforum.com/member.php...o&userid=23008
View this thread: http://www.excelforum.com/showthread...hreadid=378345



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

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