Uma família de softwares de planilhas da Microsoft com ferramentas para analisar, criar gráficos e comunicar dados
Esta resposta foi traduzida automaticamente. Como resultado, pode haver erros gramaticais ou palavras estranhas.
Você pode tentar macro.
Sub AA()
TargetValue = 6172.20001
TargetCount = 10
CompareValue = 0
For A = 0 To 1
For B = 0 To 1
For C = 0 To 1
For D = 0 To 1
For E = 0 To 1
For F = 0 To 1
For G = 0 To 1
For H = 0 To 1
For I = 0 To 1
For J = 0 To 1
For K = 0 To 1
For L = 0 To 1
For M = 0 To 1
For N = 0 To 1
For O = 0 To 1
CountValue = A + B + C + D + E + F + G + H + I + J + K + L + M + N + O
SumProValue = Cells(2, 1) * A + Cells(3, 1) * B + Cells(4, 1) * C + Cells(5, 1) * D + Cells(6, 1) * E + Cells(7, 1) * F + Cells(8, 1) * G + Cells(9, 1) * H + Cells(10, 1) * I + Cells(11, 1) * J + Cells(12, 1) * K + Cells(13, 1) * L + Cells(14, 1) * M + Cells(15, 1) * N + Cells(16, 1) * O
If SumProValue > CompareValue And SumProValue < TargetValue And CountValue = TargetCount Then
CompareValue = SumProValue
Cells(2, 2) = A
Cells(3, 2) = B
Cells(4, 2) = C
Cells(5, 2) = D
Cells(6, 2) = E
Cells(7, 2) = F
Cells(8, 2) = G
Cells(9, 2) = H
Cells(10, 2) = I
Cells(11, 2) = J
Cells(12, 2) = K
Cells(13, 2) = L
Cells(14, 2) = M
Cells(15, 2) = N
Cells(16, 2) = O
End If
Next O
Next N
Next M
Next L
Next K
Next J
Next I
Next H
Next G
Next F
Next E
Next D
Next C
Next B
Next A
End Sub