PC Review


Reply
Thread Tools Rate Thread

Another Simple GoalSeek question ??

 
 
monir
Guest
Posts: n/a
 
      25th Nov 2008
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 With Quote
 
 
 
 
paul.robinson@it-tallaght.ie
Guest
Posts: n/a
 
      25th Nov 2008
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 <mo...@discussions.microsoft.com> 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 With Quote
 
monir
Guest
Posts: n/a
 
      25th Nov 2008
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.


"(E-Mail Removed)" 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 <mo...@discussions.microsoft.com> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
simple simple question about command-prompt window riprap Windows XP General 9 6th Nov 2008 02:55 PM
IF formula-simple question; simple operator Rich D Microsoft Excel Misc 4 6th Dec 2007 03:36 PM
A simple question requiring a simple answer Pedros Microsoft Excel Discussion 3 18th Jul 2006 11:40 AM
Simple Simple Excel usage question =?Utf-8?B?Qm9va2VyVw==?= Microsoft Excel Misc 1 23rd Jun 2005 10:06 PM
Simple Question and hopefully a simple answer re- spam News Microsoft Outlook 9 31st May 2005 03:07 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:30 AM.