Skip to content

Instantly share code, notes, and snippets.

@kris7t
Created February 8, 2013 15:48
Show Gist options
  • Save kris7t/4739854 to your computer and use it in GitHub Desktop.
Save kris7t/4739854 to your computer and use it in GitHub Desktop.
Sub Foobar
Dim Doc as Object
Dim Sheet as Object
Dim VariableCell as Object
Dim TargetCell as Object
Const LowerBound = -1
Const UpperBound = 5
Dim Variable as Double
Dim MaxLoc as Double
Dim MaxValue as Double
Dim Column as Integer
Dim SheetIndex as Integer
For SheetIndex = 1 to 4
For Column = 11 To 14
Doc = ThisComponent
Sheet = Doc.Sheets(SheetIndex)
VariableCell = Sheet.GetCellByPosition(Column,1)
TargetCell = Sheet.GetCellByPosition(Column,13)
Variable = LowerBound
MaxLoc = LowerBound
MaxValue = -1
Do While Variable <= UpperBound
VariableCell.Value = Variable
If MaxValue < TargetCell.Value Then
MaxLoc = Variable
MaxValue = TargetCell.Value
End If
Variable = Variable + 0.01
Loop
VariableCell.Value = MaxLoc
Next Column
Next SheetIndex
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment