Pagina precedente | 1 | Pagina successiva
Vota | Stampa | Notifica email    
Autore

Seleziona Area e calcola Ritardi

Ultimo Aggiornamento: 05/07/2020 12:12
Post: 1.257
Registrato il: 27/06/2011
Utente Veteran
excel 2007
OFFLINE
23/05/2019 00:44

ciao a tutti [SM=x423028]

ciao Sal, Giuseppe e Matteo,
azz, sono arrivato tardi e Matteo ha cambiato la struttura del file.

Credo che quello che cercasse con il suo file al post #4,
sia nel file che allego.

Di seguito la macro.
Spero di non avere lasciato dei refusi.

ciao
Frank

vb
Option Explicit
Sub ritardi()
Dim rng_estrazione As Range, rng_tabellone As Range
Dim rng_ritardi As Range, cella As Range, rng_risultati As Range

Dim c_estrazione As Object, tabellone As Object
Dim ritardo As Integer
Dim ur As Long, c As Long, r As Long
 
ur = Cells(Rows.Count, "d").End(xlUp).Row

Set rng_tabellone = Uni0n(Range("i2:i21"), Range("k2:k21"), _
    Range("m2:m21"), Range("o2:o21"), Range("q2:q21"))
Set rng_risultati = Uni0n(Range("j2:j21"), Range("l2:l21"), _
    Range("n2:n21"), Range("p2:p21"), Range("r2:r21"))
    
Set rng_ritardi = Range("c2:h" & ur)
Set rng_estrazione = Range("d1:h1")

Application.ScreenUpdating = False

rng_risultati.ClearContents

For Each cella In rng_ritardi
    If IsNumeric(cella.Value) = False Then
    Else
        Set c_estrazione = rng_estrazione.Find(cella.Value, LookIn:=xlValues, lookat:=xlWhole)
        If Not c_estrazione Is Nothing Then
            ritardo = 0
        Else
            ritardo = cella.Row - 1
        End If
       
    
        Set tabellone = rng_tabellone.Find(cella.Value, LookIn:=xlValues, lookat:=xlWhole)
        r = tabellone.Row
        c = tabellone.Column
        If Cells(r, c + 1).Value <> "" Then
        Else
            Cells(r, c + 1).Value = ritardo
        End If
    End If
Next cella
Application.ScreenUpdating = True

Set c_estrazione = Nothing
Set tabellone = Nothing
Set rng_ritardi = Nothing
Set rng_estrazione = Nothing
Set rng_tabellone = Nothing
Set rng_risultati = Nothing
End Sub


[Modificato da tanimon 23/05/2019 01:14]







Stretta la foglia, larga la via, dite la vostra che ho detto la mia.
Excel 2007 forse anche 2013 ... 2021 ... 365 e future...
Vota: 15MediaObject5,00428 4
Amministra Discussione: | Chiudi | Sposta | Cancella | Modifica | Notifica email Pagina precedente | 1 | Pagina successiva
Nuova Discussione
 | 
Rispondi
Cerca nel forum
Tag discussione
Discussioni Simili   [vedi tutte]
Feed | Forum | Bacheca | Album | Utenti | Cerca | Login | Registrati | Amministra
Tutti gli orari sono GMT+01:00. Adesso sono le 17:04. Versione: Stampabile | Mobile | Regolamento | Privacy
FreeForumZone [v.6.1] - Copyright © 2000-2024 FFZ srl - www.freeforumzone.com