I would highly appreciate if anyone can help me with this problem: <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com
ffice
ffice" /><o
></o
>
<o
></o
>
I use the following macro (below). It works perfect, however I often add columns in the worksheet, and then I have to change the column names in the VBA formula (e.g. from BD to BE). Is it possible to make the column reference dynamic, such that if I add a column in the worksheet, I do not have to change the reference in VBA code? <o
></o
>
Sub Optimize_TV()
'
' Optimize_TV Macro
'
'
Worksheets("Calculations").Activate
RowCount = 12
Do While Not IsEmpty(Worksheets("Calculations").Range("B" & RowCount))
SolverReset
SolverOk SetCell:=Range("BD" & RowCount), MaxMinVal:=1, ValueOf:=0, ByChange:=Range("BF" & RowCount), Engine _
:=1, EngineDesc:="GRG Nonlinear"
SolverAdd CellRef:=Range("BE" & RowCount), Relation:=1, FormulaText:=Range("AY" & RowCount)
SolverAdd CellRef:=Range("BE" & RowCount), Relation:=3, FormulaText:=Range("AZ" & RowCount)
SolverOk SetCell:=Range("BD" & RowCount), MaxMinVal:=1, ValueOf:=0, ByChange:=("BF" & RowCount), Engine _
:=1, EngineDesc:="GRG Nonlinear"
SolverSolve userFinish:=True
SolverFinish keepFinal:=1
RowCount = RowCount + 1
Loop
End Sub
Thanks for all help!
Thanks




<o


I use the following macro (below). It works perfect, however I often add columns in the worksheet, and then I have to change the column names in the VBA formula (e.g. from BD to BE). Is it possible to make the column reference dynamic, such that if I add a column in the worksheet, I do not have to change the reference in VBA code? <o


Sub Optimize_TV()
'
' Optimize_TV Macro
'
'
Worksheets("Calculations").Activate
RowCount = 12
Do While Not IsEmpty(Worksheets("Calculations").Range("B" & RowCount))
SolverReset
SolverOk SetCell:=Range("BD" & RowCount), MaxMinVal:=1, ValueOf:=0, ByChange:=Range("BF" & RowCount), Engine _
:=1, EngineDesc:="GRG Nonlinear"
SolverAdd CellRef:=Range("BE" & RowCount), Relation:=1, FormulaText:=Range("AY" & RowCount)
SolverAdd CellRef:=Range("BE" & RowCount), Relation:=3, FormulaText:=Range("AZ" & RowCount)
SolverOk SetCell:=Range("BD" & RowCount), MaxMinVal:=1, ValueOf:=0, ByChange:=("BF" & RowCount), Engine _
:=1, EngineDesc:="GRG Nonlinear"
SolverSolve userFinish:=True
SolverFinish keepFinal:=1
RowCount = RowCount + 1
Loop
End Sub
Thanks for all help!
Thanks