Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 19
Default Macro for iterations....

I have a multisheet database that is affected by a parameter in cell C5 which
has a range of from -.4 to 1.25, and can be adjusted in increments of .05

The impact of changes to C1 are summarized in cell G5

Can I create a macro that will find the maximimum value displayed in G5 by
iterating C1 through the above ranges in .05 increments?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Macro for iterations....

Consider using Solver
--
Gary''s Student - gsnu200716


"Nick Krill" wrote:

I have a multisheet database that is affected by a parameter in cell C5 which
has a range of from -.4 to 1.25, and can be adjusted in increments of .05

The impact of changes to C1 are summarized in cell G5

Can I create a macro that will find the maximimum value displayed in G5 by
iterating C1 through the above ranges in .05 increments?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Macro for iterations....

I'm confused about what cell you're changing--is it C5 or C1???

I guessed C1:

Option Explicit
Sub testme()

Dim myInc As Double

Dim myInputCell As Range
Dim myOutputCell As Range

Dim myMaxOut As Double
Dim myMaxIn As Double

Dim NewMax As Boolean

Dim myStart As Double
Dim myEnd As Double
Dim myStep As Double

myStart = -0.4
myEnd = 1.25
myStep = 0.05

With Worksheets("sheet1")
Set myInputCell = .Range("C1")
Set myOutputCell = .Range("G5")
For myInc = myStart To myEnd Step myStep
myInputCell.Value = myInc
If myInc = myStart Then
'gotta start somewhere
NewMax = True
ElseIf myOutputCell.Value myMaxOut Then
'a real new max
NewMax = True
Else
'keep looking
NewMax = False
End If
If NewMax = True Then
myMaxOut = myOutputCell.Value
myMaxIn = myInputCell.Value
End If
Next myInc
End With

MsgBox "Max at: " & myMaxIn & vbLf & "Max of: " & myMaxOut

End Sub



Nick Krill wrote:

I have a multisheet database that is affected by a parameter in cell C5 which
has a range of from -.4 to 1.25, and can be adjusted in increments of .05

The impact of changes to C1 are summarized in cell G5

Can I create a macro that will find the maximimum value displayed in G5 by
iterating C1 through the above ranges in .05 increments?


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 19
Default Macro for iterations....

Thank you ever so much - this worked fabulously!

"Dave Peterson" wrote:

I'm confused about what cell you're changing--is it C5 or C1???

I guessed C1:

Option Explicit
Sub testme()

Dim myInc As Double

Dim myInputCell As Range
Dim myOutputCell As Range

Dim myMaxOut As Double
Dim myMaxIn As Double

Dim NewMax As Boolean

Dim myStart As Double
Dim myEnd As Double
Dim myStep As Double

myStart = -0.4
myEnd = 1.25
myStep = 0.05

With Worksheets("sheet1")
Set myInputCell = .Range("C1")
Set myOutputCell = .Range("G5")
For myInc = myStart To myEnd Step myStep
myInputCell.Value = myInc
If myInc = myStart Then
'gotta start somewhere
NewMax = True
ElseIf myOutputCell.Value myMaxOut Then
'a real new max
NewMax = True
Else
'keep looking
NewMax = False
End If
If NewMax = True Then
myMaxOut = myOutputCell.Value
myMaxIn = myInputCell.Value
End If
Next myInc
End With

MsgBox "Max at: " & myMaxIn & vbLf & "Max of: " & myMaxOut

End Sub



Nick Krill wrote:

I have a multisheet database that is affected by a parameter in cell C5 which
has a range of from -.4 to 1.25, and can be adjusted in increments of .05

The impact of changes to C1 are summarized in cell G5

Can I create a macro that will find the maximimum value displayed in G5 by
iterating C1 through the above ranges in .05 increments?


--

Dave Peterson

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
Iterations antonje New Users to Excel 2 October 10th 06 08:11 PM
copying data during iterations aminal Excel Discussion (Misc queries) 6 July 27th 06 01:33 AM
How do I turn iterations off permanently? Dennis Excel Discussion (Misc queries) 3 May 7th 06 06:17 PM
Is there a way where I can default iterations Kelseyk Excel Discussion (Misc queries) 0 March 28th 06 12:49 AM
How do i compute the average value of 100 iterations? il_102 Excel Worksheet Functions 4 November 23rd 05 04:29 PM


All times are GMT +1. The time now is 07:07 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"