Столкнулся со следующей проблемой. Не могу воспользоваться функцией GoalSeek посредством пользовательской функции вводимой пользователем прямо в ячейку Excel. Работает только через GS() вызываемой через Alt+F8. Посредством ввода в ячейку =iGoalSeek(B5;B2;B3) или =sGoalSeek(5; 2; 2; 2; 3; 2) ничего не получается.
- Код: Выделить всё
Public Function iGoalSeek(iRange As Range, _
iGoal As Range, _
iChangingCell As Range)
Dim ir As Long
Dim jr As Long
Dim ig As Long
Dim jg As Long
Dim ic As Long
Dim jc As Long
ir = iRange.Row
jr = iRange.Column
ig = iGoal.Row
jg = iGoal.Column
ic = iChangingCell.Row
jc = iChangingCell.Column
fGoalSeek ir, jr, ig, jg, ic, jc
End Function
Function sGoalSeek(ir As Long, _
jr As Long, _
ig As Long, _
jg As Long, _
ic As Long, _
jc As Long)
fGoalSeek ir, jr, ig, jg, ic, jc
End Function
Sub GS()
fGoalSeek 5, 2, 2, 2, 3, 2
End Sub
Public Sub fGoalSeek(ir As Long, _
jr As Long, _
ig As Long, _
jg As Long, _
ic As Long, _
jc As Long)
Dim iRange As Range
Dim iGoal As Range
Dim iChangingCell As Range
Set iRange = Cells(ir, jr) 'ActiveCell
Set iGoal = Cells(ig, jg) '"B2"
Set iChangingCell = Cells(ic, jc) '"B3"
iRange.GoalSeek Goal:=iGoal.Value, ChangingCell:=iChangingCell
End Sub
Заранее спасибо!