PC Review


Reply
Thread Tools Rate Thread

Do Loop Goal Seek won't End Sub

 
 
=?Utf-8?B?U2hhcm9u?=
Guest
Posts: n/a
 
      14th Nov 2007
I am just a novice & wrote a simple do loop for goal seeking. The goal seek
calculates however, the macro won't End Sub. The debugging highlights the
3rd to the last line below : Cells(81, i).GoalSeek Goal:=0,
ChangingCell:=Cells(74, i)



Sub GoalSeek()

'select/copy values
Range("AY79:BJ79").Copy
Range("AY76:BJ76").Select
Selection.PasteSpecial Paste:=xlValues


'set variables
Dim r As Integer, i As Integer
'assign column value to varibles
r = 50
i = 0

Cells(81, r).Select

Do
r = r + 1

Loop Until Cells(81, r) = "end"

For i = 51 To r

'goal seek
'set cell range (row 81) to 0 by adjusting 100% (row 74)
Cells(81, i).GoalSeek Goal:=0, ChangingCell:=Cells(74, i)

Next i

End Sub

 
Reply With Quote
 
 
 
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      15th Nov 2007
There is nothing in your macro that would make Cells(81, r) = "end".

That is why your loop runs continuously. You could set it to loop until r =
456 which would be the last column of the sheet up throught XL2003. It goes
a lot higher than that in 2007.

"Sharon" wrote:

> I am just a novice & wrote a simple do loop for goal seeking. The goal seek
> calculates however, the macro won't End Sub. The debugging highlights the
> 3rd to the last line below : Cells(81, i).GoalSeek Goal:=0,
> ChangingCell:=Cells(74, i)
>
>
>
> Sub GoalSeek()
>
> 'select/copy values
> Range("AY79:BJ79").Copy
> Range("AY76:BJ76").Select
> Selection.PasteSpecial Paste:=xlValues
>
>
> 'set variables
> Dim r As Integer, i As Integer
> 'assign column value to varibles
> r = 50
> i = 0
>
> Cells(81, r).Select
>
> Do
> r = r + 1
>
> Loop Until Cells(81, r) = "end"
>
> For i = 51 To r
>
> 'goal seek
> 'set cell range (row 81) to 0 by adjusting 100% (row 74)
> Cells(81, i).GoalSeek Goal:=0, ChangingCell:=Cells(74, i)
>
> Next i
>
> End Sub
>

 
Reply With Quote
 
carlo
Guest
Posts: n/a
 
      15th Nov 2007
I think JLGWhiz meant 256 not 456!

the rest he sais is true.

cheers

carlo

On Nov 15, 1:18 pm, JLGWhiz <JLGW...@discussions.microsoft.com> wrote:
> There is nothing in your macro that would make Cells(81, r) = "end".
>
> That is why your loop runs continuously. You could set it to loop until r =
> 456 which would be the last column of the sheet up throught XL2003. It goes
> a lot higher than that in 2007.
>
>
>
> "Sharon" wrote:
> > I am just a novice & wrote a simple do loop for goal seeking. The goal seek
> > calculates however, the macro won't End Sub. The debugging highlights the
> > 3rd to the last line below : Cells(81, i).GoalSeek Goal:=0,
> > ChangingCell:=Cells(74, i)

>
> > Sub GoalSeek()

>
> > 'select/copy values
> > Range("AY79:BJ79").Copy
> > Range("AY76:BJ76").Select
> > Selection.PasteSpecial Paste:=xlValues

>
> > 'set variables
> > Dim r As Integer, i As Integer
> > 'assign column value to varibles
> > r = 50
> > i = 0

>
> > Cells(81, r).Select

>
> > Do
> > r = r + 1

>
> > Loop Until Cells(81, r) = "end"

>
> > For i = 51 To r

>
> > 'goal seek
> > 'set cell range (row 81) to 0 by adjusting 100% (row 74)
> > Cells(81, i).GoalSeek Goal:=0, ChangingCell:=Cells(74, i)

>
> > Next i

>
> > End Sub- Hide quoted text -

>
> - Show quoted text -


 
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
Loop several sheets - part 4 - Dave Peterson - Goal seek al Microsoft Excel Programming 1 25th Jan 2009 11:28 PM
Loop several sheets - part 3 - Dave Peterson - Goal seek al Microsoft Excel Programming 4 25th Jan 2009 10:12 PM
Goal Seek in a loop =?Utf-8?B?QnJvdGhlcg==?= Microsoft Excel Misc 3 3rd Oct 2007 08:22 PM
Re: goal seek in a loop Peo Sjoblom Microsoft Excel Misc 0 3rd Oct 2007 06:54 PM
goal seek in a loop =?Utf-8?B?ZGF2ZQ==?= Microsoft Excel Misc 0 3rd Oct 2007 06:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:38 AM.