Moderatori: Anthony47, Flash30005
Function FanSost(ByRef TitVoti As Range, ByRef TitRuol As Range, ByRef ReplVoti As Range, ByRef ReplRuol As Range) As Variant
Dim I As Long, J As Long, TotRep As Long, myRes()
'
ReDim myRes(1 To ReplVoti.Count)
ReDim myScr(1 To ReplVoti.Count)
myScr = ReplRuol.Value
For I = 1 To TitVoti.Count
If TitVoti.Cells(I, 1) = "-" Or TitVoti.Cells(I, 1) = " " Or TitVoti.Cells(I, 1) = 0 Then
If TotRep < 3 Then
For J = 1 To ReplVoti.Count
If myScr(J, 1) = TitRuol.Cells(I, 1) And IsNumeric(ReplVoti.Cells(J, 1)) And ReplVoti.Cells(J, 1) > 0 Then
myRes(J) = ReplVoti.Cells(J, 1).Value
myScr(J, 1) = ""
If UCase(TitRuol.Cells(I, 1)) <> "P" Then TotRep = TotRep + 1
If TotRep > 2 Then GoTo Esci Else Exit For
End If
Next J
End If
End If
Next I
Esci:
If Parent.Caller.Rows.Count > 1 Then myRes = Application.WorksheetFunction.Transpose(myRes)
FanSost = myRes
End Function
=FanSost($F$4:$F$14;C4:C14;E15:E21;C15:C21)
Metti il codice in un nuovo Modulo del vba (es Modulo1), poi selezioni F15:F21 e inserisci la formula
- Codice: Seleziona tutto
=FanSost($F$4:$F$14;C4:C14;E15:E21;C15:C21)
da confermare con Contr-Maiusc-Enter
Io lo interpreto che il portiere si sostituiesce e non viene contato nel limite dei 3.ad esclusione del portiere ( B15 ) [. . . ]
In mancanza di questa precisazione io invece sostituisco guardando nei titolari: al primo che deve essere sostituito vado a pescare il panchinaro. Non capisco la logica all' incontrario, ma se e' così bisognera' modificare la "funzione"; hai aspettato tanto, aspetterai ancora qualche ora...deve sostituire 3 panchinari in ordine di inserimento numerico B16:B21...
Function FanSost(ByRef TitVoti As Range, ByRef TitRuol As Range, ByRef ReplVoti As Range, ByRef ReplRuol As Range) As Variant
Dim I As Long, J As Long, TotRep As Long, myRes()
'
ReDim myRes(1 To ReplVoti.Count)
ReDim myScr(1 To TitVoti.Count)
myScr = TitRuol.Value
'
For I = 1 To ReplVoti.Count
If ReplVoti.Cells(I, 1) <> "-" And ReplVoti.Cells(I, 1) <> " " And ReplVoti.Cells(I, 1) > 0 Then
If TotRep < 3 Then
For J = 1 To TitVoti.Count
If UCase(myScr(J, 1)) = UCase(ReplRuol.Cells(I, 1)) And (Not IsNumeric(TitVoti.Cells(J, 1)) Or TitVoti.Cells(J, 1) = 0) Then
myRes(I) = ReplVoti.Cells(I, 1).Value
myScr(J, 1) = ""
If UCase(TitRuol.Cells(I, 1)) <> "P" Then TotRep = TotRep + 1
If TotRep > 2 Then GoTo Esci Else Exit For
End If
Next J
End If
End If
Next I
Esci:
If Parent.Caller.Rows.Count > 1 Then myRes = Application.WorksheetFunction.Transpose(myRes)
FanSost = myRes
End Function
Torna a Applicazioni Office Windows
Modidica Formula Somma I Riferimenti Autore: Francesco6918 |
Forum: Applicazioni Office Windows Risposte: 2 |
Excel: formula automatica per evidenziare prodotto scaduto Autore: gamma_ray |
Forum: Applicazioni Office Windows Risposte: 3 |
formula excel non visualizza risultato Autore: tommasog |
Forum: Applicazioni Office Windows Risposte: 6 |
Formula per proporzionare un numero Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 4 |
Visitano il forum: Nessuno e 43 ospiti