Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 215
Default Another Simple GoalSeek question ??

Hello;

How can I change the fill in the changingCell to, say, ColorIndex = 15, if
the goalSeek is successfull ??
Currently, I've in a loop:
Cells(myrow, colSet).GoalSeek Goal:=Cells(myrow, colVal), _
ChangingCell:=Cells(myrow2, colChange)
If GoalSeekVal = True Then Cells(myrow2, colChange).Interior.ColorIndex =
15

The color doesn't change. Apparantly, "GoalSeekVal" is not the correct
variable name in the GoalSeek method. It remains empty while the method is
successful. "True" is likely returned to something else!

Regards.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Another Simple GoalSeek question ??

Hi
Try this
Dim GoalSeekVal as Boolean
GoalSeekVal = Cells(myrow, colSet).GoalSeek(Goal:=Cells(myrow,
colVal), _
ChangingCell:=Cells(myrow2, colChange))
If GoalSeekVal = True Then Cells(myrow2,
colChange).Interior.ColorIndex = 15

or possibly this

Dim GoalSeekVal as Boolean
GoalSeekVal = Cells(myrow, colSet).GoalSeek(Cells(myrow, colVal), _
Cells(myrow2, colChange))
If GoalSeekVal = True Then Cells(myrow2,
colChange).Interior.ColorIndex = 15

untested
regards
Paul

On Nov 25, 1:06*am, monir wrote:
Hello;

How can I change the fill in the changingCell to, say, ColorIndex = 15, if
the goalSeek is successfull ??
Currently, I've in a loop:
* *Cells(myrow, colSet).GoalSeek Goal:=Cells(myrow, colVal), _
* * * * * * * * * * * * ChangingCell:=Cells(myrow2, colChange)
* *If GoalSeekVal = True Then Cells(myrow2, colChange).Interior.ColorIndex =
15

The color doesn't change. *Apparantly, "GoalSeekVal" is not the correct
variable name in the GoalSeek method. *It remains empty while the method is
successful. *"True" is likely returned to something else!

Regards.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 215
Default Another Simple GoalSeek question ??

Paul;

Thank you for your reply.
It seems that the variable GoalSeekVal may or may not be declared as
Boolean, but the method arguments must be included in parentheses if the
GoalSeek return value is assigned to a variable (GoalSeekVal in my example).
However, when using parentheses, including the names of arguments is optional.

Dim myChngCell As Range
Set myChngCell = Cells(myRow2, colByChange)
GoalSeekVal = Cells(myRow, colSet).GoalSeek(Cells(myRow, colToVal),
myChngCell)
If GoalSeekVal = True Then myChngCell.Interior.ColorIndex = 15

I concur with MrExcel Emma's observation: " GoalSeek seems to return False
if ChangingCell already has the correct value. Which could be annoying.".

Regards.


" wrote:

Hi
Try this
Dim GoalSeekVal as Boolean
GoalSeekVal = Cells(myrow, colSet).GoalSeek(Goal:=Cells(myrow,
colVal), _
ChangingCell:=Cells(myrow2, colChange))
If GoalSeekVal = True Then Cells(myrow2,
colChange).Interior.ColorIndex = 15

or possibly this

Dim GoalSeekVal as Boolean
GoalSeekVal = Cells(myrow, colSet).GoalSeek(Cells(myrow, colVal), _
Cells(myrow2, colChange))
If GoalSeekVal = True Then Cells(myrow2,
colChange).Interior.ColorIndex = 15

untested
regards
Paul

On Nov 25, 1:06 am, monir wrote:
Hello;

How can I change the fill in the changingCell to, say, ColorIndex = 15, if
the goalSeek is successfull ??
Currently, I've in a loop:
Cells(myrow, colSet).GoalSeek Goal:=Cells(myrow, colVal), _
ChangingCell:=Cells(myrow2, colChange)
If GoalSeekVal = True Then Cells(myrow2, colChange).Interior.ColorIndex =
15

The color doesn't change. Apparantly, "GoalSeekVal" is not the correct
variable name in the GoalSeek method. It remains empty while the method is
successful. "True" is likely returned to something else!

Regards.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF formula-simple question; simple operator Rich D Excel Discussion (Misc queries) 4 December 6th 07 03:36 PM
GoalSeek in VBA [email protected] Excel Discussion (Misc queries) 1 July 20th 06 05:13 AM
mimic goalseek Monique Excel Programming 6 August 25th 05 07:11 PM
Simple Simple Excel usage question BookerW Excel Discussion (Misc queries) 1 June 23rd 05 10:06 PM
simple question, hopefully a simple answer! Matt B Excel Programming 5 January 13th 04 08:43 PM


All times are GMT +1. The time now is 01:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"