Я снова ... Работаю над тем же проектом с другой проблемой!
У меня есть 3 значения (расчеты, но мне просто нужно результирующее значение), только 1 из которых мне нужно вставить в первую ячейку моего графика амортизации. Когда значение вставлено, ячейка LAST должна быть равна 0 или близка к ней.
В настоящее время мой цикл продолжается до бесконечности.
Dim LastCell As Range: Set LastCell = Destination.Offset(9, 12).End(xlDown) 'Last cell of
'the amort schedule, should be 0 or close to it at end of term. Destination is a named cell,
'I'm getting better at avoiding ActiveCell!
Dim PV1 As Double: PV1 = Destination.Offset(0, 12) '2440754.76
Dim PV2 As Double: PV2 = Destination.Offset(1, 12) '2400379.97 This is the value in my
'current scenario that I need, but it may not always be the case
Dim PV3 As Double: PV3 = Destination.Offset(2, 12) '2429942.76
Dim UseCalc As Range: Set UseCalc = Destination.Offset(9, 12) 'First cell of the amort schedule
Do Until (LastCell.Value >= -1 And LastCell.Value <= 1)
UseCalc = PV1
UseCalc = PV2 'When it gets to this point, I can see the value in LastCell
'becomes 1.0000000000001839362E-02 which SHOULD trip the between -1 and 1 threshold,
'but I'm sure something in the variables I'm setting are going wacky
UseCalc = PV3
Loop
Я предполагаю, что комбинация переменных, которую я использую, не является правильной, и поэтому она не отключает «До», но я попробовал каждую разумную комбинацию, которую только могу придумать. Заранее спасибо!