Esta função macro funcionará:
Public Function resourceDays(resourceName As String, totalDays As Integer, totalResources As String)
resourceDays = 0
Dim eachResource() As String
eachResource = Split(totalResources, ",")
totalValues = 0
For i = 0 To UBound(eachResource)
thisresource = eachResource(i)
startPct = InStr(thisresource, "[")
If startPct = 0 Then
resourceValue = 1
totalValues = totalValues + resourceValue
If UCase(Trim(thisresource)) = UCase(Trim(resourceName)) Then
thisvalue = resourceValue
End If
Else
endPct = InStr(thisresource, "%")
PctValue = (Mid(thisresource, startPct + 1, endPct - startPct - 1)) / 100
Tempresource = Mid(thisresource, 1, startPct - 1)
resourceValue = PctValue
totalValues = totalValues + resourceValue
If UCase(Trim(Tempresource)) = UCase(Trim(resourceName)) Then
thisvalue = resourceValue
End If
End If
Next i
resourceDays = totalDays * (thisvalue / totalValues)
End Function
Abra o VBA / Macros com Alt + F11 , sob ThisWorkbook insira um novo módulo e cole o código no lado direito.
Na célula D2 coloque a fórmula =resourceDays(D1,B2,C2)
, onde os parâmetros são
resourceDays=(Name of Resource, Total Of Days, String Of Total Resources)
.