Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 183
Default Do Loop Goal Seek won't End Sub

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Do Loop Goal Seek won't End Sub

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 367
Default Do Loop Goal Seek won't End Sub

I think JLGWhiz meant 256 not 456!

the rest he sais is true.

cheers

carlo

On Nov 15, 1:18 pm, JLGWhiz 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
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
Goal Seek in a loop Brother Excel Discussion (Misc queries) 3 October 3rd 07 08:22 PM
goal seek in a loop dave Excel Discussion (Misc queries) 1 October 3rd 07 06:54 PM
Vba goal seek csw78 Excel Programming 9 July 15th 05 11:38 AM
vba goal seek 2 csw78[_3_] Excel Programming 1 June 12th 05 08:24 PM
Goal Seek Tiya Excel Worksheet Functions 1 May 11th 05 12:38 PM


All times are GMT +1. The time now is 04:54 AM.

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

About Us

"It's about Microsoft Excel"