Moderatori: Anthony47, Flash30005
Sub TrovaSpia() '............................................................................................
Set Ws1 = Worksheets("Archivio")
Set Ws2 = Worksheets("Attuali")
For CCA = 48 To 3 Step -5
Dim VNA(5) As Integer
Dim VNC(90) As Integer
RuA = UCase(Trim(Ws1.Cells(1, CCA)))
VNC(1) = Ws1.Cells(2, CCA).Value
VNC(2) = Ws1.Cells(2, CCA + 1).Value
VNC(3) = Ws1.Cells(2, CCA + 2).Value
VNC(4) = Ws1.Cells(2, CCA + 3).Value
VNC(5) = Ws1.Cells(2, CCA + 4).Value
CCV = 0
For NV = 1 To 90
For Onu = 1 To 5
If NV = Ws1.Cells(2, CCA + Onu - 1).Value Then
CCV = CCV + 1
VNA(CCV) = Ws1.Cells(2, CCA + Onu - 1).Value
End If
Next Onu
Next NV
NewR = Ws2.Range("B" & Rows.Count).End(xlUp).Row
For NVR = 5 To 1 Step -1
For RR1 = NewR To 8 Step -1
If UCase(Trim(Ws2.Range("B" & RR1).Value)) = UCase(Trim(RuA)) Then
If Trim(Ws2.Range("N" & RR1).Value) = "Sto" And Ws2.Range("J" & RR1 + 1).Value <> 0 Then
Rows(RR1 + 1 & ":" & RR1 + 1).Insert Shift:=xlDown
Ws2.Range("A" & RR1 & ":P" & RR1).Copy Destination:=Ws2.Range("A" & RR1 + 1)
Application.CutCopyMode = False
Ws2.Range("J" & RR1 + 1).Value = 0
Ws2.Range("K" & RR1 + 1).ClearContents
Ws2.Range("N" & RR1).Value = "Att"
Ws2.Range("O" & RR1 + 1).ClearContents
Ws2.Range("P" & RR1).Value = "in corso"
End If
If VNA(NVR) = Ws2.Cells(RR1, 3).Value And Trim(Ws2.Range("N" & RR1).Value) <> "Sto" Then
Rows(RR1 + 1 & ":" & RR1 + 1).Insert Shift:=xlDown
Ws2.Range("A" & RR1 & ":P" & RR1).Copy Destination:=Ws2.Range("A" & RR1 + 1)
Application.CutCopyMode = False
Ws2.Range("I" & RR1 + 1).Value = Ws1.Range("A2").Value
Ws2.Cells(RR1 + 1, 13).Value = CDate(Ws1.Range("B2").Value)
Ws2.Range("J" & RR1 + 1).Value = 0
NewR = RR1
GoTo SaltaNV
End If
End If
Next RR1
SaltaNV:
Next NVR
Next CCA
UR1 = Ws2.Range("B" & Rows.Count).End(xlUp).Row
For RR1 = 8 To UR1
Range("A" & RR1).Value = RR1 - 7
Next RR1
End Sub
Sub TrovaSpia() '............................................................................................
Set Ws1 = Worksheets("Archivio")
Set Ws2 = Worksheets("Attuali")
For CCA = 48 To 3 Step -5
Dim VNA(5) As Integer
Dim VNC(90) As Integer
RuA = UCase(Trim(Ws1.Cells(1, CCA)))
VNC(1) = Ws1.Cells(2, CCA).Value
VNC(2) = Ws1.Cells(2, CCA + 1).Value
VNC(3) = Ws1.Cells(2, CCA + 2).Value
VNC(4) = Ws1.Cells(2, CCA + 3).Value
VNC(5) = Ws1.Cells(2, CCA + 4).Value
CCV = 0
For NV = 1 To 90
For Onu = 1 To 5
If NV = Ws1.Cells(2, CCA + Onu - 1).Value Then
CCV = CCV + 1
VNA(CCV) = Ws1.Cells(2, CCA + Onu - 1).Value
End If
Next Onu
Next NV
NewR = Ws2.Range("B" & Rows.Count).End(xlUp).Row
For NVR = 5 To 1 Step -1
For RR1 = NewR To 8 Step -1
If Trim(Ws2.Range("N" & RR1).Value) = "Sto" And Ws2.Range("J" & RR1 + 1).Value <> 0 Then
Rows(RR1 + 1 & ":" & RR1 + 1).Insert Shift:=xlDown
Ws2.Range("A" & RR1 & ":P" & RR1).Copy Destination:=Ws2.Range("A" & RR1 + 1)
Application.CutCopyMode = False
Ws2.Range("J" & RR1 + 1).Value = 0
Ws2.Range("K" & RR1 + 1).ClearContents
Ws2.Range("N" & RR1 + 1).Value = "Att"
Ws2.Range("O" & RR1 + 1).ClearContents
Ws2.Range("P" & RR1 + 1).Value = "in corso"
End If
If UCase(Trim(Ws2.Range("B" & RR1).Value)) = UCase(Trim(RuA)) Then
If VNA(NVR) = Ws2.Cells(RR1, 3).Value And Trim(Ws2.Range("N" & RR1).Value) <> "Sto" Then
Rows(RR1 + 1 & ":" & RR1 + 1).Insert Shift:=xlDown
Ws2.Range("A" & RR1 & ":P" & RR1).Copy Destination:=Ws2.Range("A" & RR1 + 1)
Application.CutCopyMode = False
Ws2.Range("I" & RR1 + 1).Value = Ws1.Range("A2").Value
Ws2.Cells(RR1 + 1, 13).Value = CDate(Ws1.Range("B2").Value)
Ws2.Range("J" & RR1 + 1).Value = 0
NewR = RR1
GoTo SaltaNV
End If
End If
Next RR1
SaltaNV:
Next NVR
Next CCA
UR1 = Ws2.Range("B" & Rows.Count).End(xlUp).Row
For RR1 = 8 To UR1
Range("A" & RR1).Value = RR1 - 7
Next RR1
End Sub
Sub TrovaSpia() '............................................................................................
Set Ws1 = Worksheets("Archivio")
Set Ws2 = Worksheets("Attuali")
For CCA = 48 To 3 Step -5
Dim VNA(5) As Integer
Dim VNC(90) As Integer
RuA = UCase(Trim(Ws1.Cells(1, CCA)))
VNC(1) = Ws1.Cells(2, CCA).Value
VNC(2) = Ws1.Cells(2, CCA + 1).Value
VNC(3) = Ws1.Cells(2, CCA + 2).Value
VNC(4) = Ws1.Cells(2, CCA + 3).Value
VNC(5) = Ws1.Cells(2, CCA + 4).Value
CCV = 0
For NV = 1 To 90
For Onu = 1 To 5
If NV = Ws1.Cells(2, CCA + Onu - 1).Value Then
CCV = CCV + 1
VNA(CCV) = Ws1.Cells(2, CCA + Onu - 1).Value
End If
Next Onu
Next NV
NewR = Ws2.Range("B" & Rows.Count).End(xlUp).Row
For NVR = 5 To 1 Step -1
For RR1 = NewR To 8 Step -1
If Trim(Ws2.Range("N" & RR1).Value) = "Sto" And Ws2.Range("J" & RR1 + 1).Value <> 0 Then
Rows(RR1 + 1 & ":" & RR1 + 1).Insert Shift:=xlDown
Ws2.Range("A" & RR1 & ":P" & RR1).Copy Destination:=Ws2.Range("A" & RR1 + 1)
Application.CutCopyMode = False
Ws2.Range("J" & RR1 + 1).Value = 0
Ws2.Range("K" & RR1 + 1).ClearContents
Ws2.Range("N" & RR1 + 1).Value = "Att"
Ws2.Range("O" & RR1 + 1).ClearContents
Ws2.Range("P" & RR1 + 1).Value = "in corso"
Ws2.Range("R" & RR1 + 1).Value = 1
Ws2.Range("S" & RR1 + 1).Value = 0
End If
If UCase(Trim(Ws2.Range("B" & RR1).Value)) = UCase(Trim(RuA)) Then
If VNA(NVR) = Ws2.Cells(RR1, 3).Value And Trim(Ws2.Range("N" & RR1).Value) <> "Sto" Then
Rows(RR1 + 1 & ":" & RR1 + 1).Insert Shift:=xlDown
Ws2.Range("A" & RR1 & ":P" & RR1).Copy Destination:=Ws2.Range("A" & RR1 + 1)
Application.CutCopyMode = False
Ws2.Range("I" & RR1 + 1).Value = Ws1.Range("A2").Value
Ws2.Cells(RR1 + 1, 13).Value = CDate(Ws1.Range("B2").Value)
Ws2.Range("J" & RR1 + 1).Value = 0
NewR = RR1
GoTo SaltaNV
End If
End If
Next RR1
SaltaNV:
Next NVR
Next CCA
UR1 = Ws2.Range("B" & Rows.Count).End(xlUp).Row
For RR1 = 8 To UR1
Range("A" & RR1).Value = RR1 - 7
Next RR1
End Sub
Lucio Peruggini ha scritto:Colonne “J-M-N” non si aggiornano i valori
Sub TrovaAgg()
Set Ws1 = Worksheets("Archivio")
Set Ws2 = Worksheets("Attuali")
AggS = 0
'Ws2.Range("K8:K1000").ClearContents
For CCA = 3 To 48 Step 5
Dim VNA(90) As Integer
RuA = UCase(Trim(Ws1.Cells(1, CCA)))
For NV = 1 To 90
For Onu = 1 To 5
If NV = Ws1.Cells(2, CCA + Onu - 1).Value Then VNA(Onu) = Ws1.Cells(2, CCA + Onu - 1).Value
Next Onu
Next NV
UR1 = Ws2.Range("B" & Rows.Count).End(xlUp).Row
For RR1 = 8 To UR1
Ambo = ""
If UCase(Trim(Ws2.Range("B" & RR1).Value)) = UCase(Trim(RuA)) Then
For NV = 1 To 5
For NP = 1 To 5
If VNA(NV) = Ws2.Cells(RR1, 3 + NP).Value Then
Ambo = Ambo & " - " & VNA(NV)
End If
Next NP
Next NV
End If
If Ws2.Cells(RR1, 12).Value < Ws1.Range("A2").Value And Trim(Trim(Ws2.Cells(RR1, 14).Value)) <> "Sto" Then '<<< ULTIMA STRINGA INSERITA
'If Ws2.Cells(RR1, 12).Value < Ws1.Range("A2").Value And Trim(Ws2.Cells(RR1, 12).Value) = "Att" Then '<<< SOSTITUITA STRINGA - If Ws2.Cells(RR1, 12).Value < Ws1.Range("A2").Value Then
AggS = 1
DiffRit = Ws1.Range("A2").Value - Ws2.Cells(RR1, 9).Value
RuA2 = UCase(Trim(Ws2.Range("B" & RR1).Value))
If RuA = RuA2 Then
If Len(Ws2.Cells(RR1, 11).Value) < 5 Then
If Len(Ambo) > 5 Then
Ws2.Cells(RR1, 12).Value = Ws1.Range("A2").Value
Ws2.Cells(RR1, 13).Value = CDate(Ws1.Range("B2").Value)
Ws2.Cells(RR1, 10).Value = DiffRit
Ws2.Cells(RR1, 14).Value = "Sto"
Ws2.Cells(RR1, 11).Value = Trim(Mid(Ambo, 3, Len(Ambo)))
Ws2.Cells(RR1, 16).Value = "Positivo"
Ws2.Cells(RR1, 15).Value = "Ambo"
If Len(Ws2.Cells(RR1, 11).Value) > 8 Then Ws2.Cells(RR1, 15).Value = "Terno"
Rows(RR1 + 1 & ":" & RR1 + 1).Insert Shift:=xlDown
Ws2.Range("A" & RR1 & ":P" & RR1).Copy Destination:=Ws2.Range("A" & RR1 + 1)
Application.CutCopyMode = False
Ws2.Range("J" & RR1 + 1).Value = 0
Ws2.Range("K" & RR1 + 1).ClearContents
Ws2.Range("L" & RR1 + 1).Value = Ws1.Range("A2").Value
Ws2.Range("M" & RR1 + 1).Value = CDate(Ws1.Range("B2").Value)
Ws2.Range("N" & RR1 + 1).Value = "Att"
Ws2.Range("O" & RR1 + 1).ClearContents
Ws2.Range("P" & RR1 + 1).Value = "in corso"
Ws2.Range("R" & RR1 + 1).Value = 1
Ws2.Range("S" & RR1 + 1).Value = 0
Else
Ws2.Cells(RR1, 10).Value = DiffRit
Ws2.Cells(RR1, 12).Value = Ws1.Range("A2").Value
Ws2.Cells(RR1, 13).Value = CDate(Ws1.Range("B2").Value)
End If
End If
End If
End If
Next RR1
Next CCA
If AggS = 1 Then TrovaSpia
End Sub
Sub TrovaSpia() '............................................................................................
Set Ws1 = Worksheets("Archivio")
Set Ws2 = Worksheets("Attuali")
For CCA = 48 To 3 Step -5
Dim VNA(5) As Integer
Dim VNC(90) As Integer
RuA = UCase(Trim(Ws1.Cells(1, CCA)))
VNC(1) = Ws1.Cells(2, CCA).Value
VNC(2) = Ws1.Cells(2, CCA + 1).Value
VNC(3) = Ws1.Cells(2, CCA + 2).Value
VNC(4) = Ws1.Cells(2, CCA + 3).Value
VNC(5) = Ws1.Cells(2, CCA + 4).Value
CCV = 0
For NV = 1 To 90
For Onu = 1 To 5
If NV = Ws1.Cells(2, CCA + Onu - 1).Value Then
CCV = CCV + 1
VNA(CCV) = Ws1.Cells(2, CCA + Onu - 1).Value
End If
Next Onu
Next NV
NewR = Ws2.Range("B" & Rows.Count).End(xlUp).Row
For NVR = 5 To 1 Step -1
For RR1 = NewR To 8 Step -1
If UCase(Trim(Ws2.Range("B" & RR1).Value)) = UCase(Trim(RuA)) Then
If VNA(NVR) = Ws2.Cells(RR1, 3).Value And Trim(Ws2.Range("N" & RR1).Value) <> "Sto" Then
Rows(RR1 + 1 & ":" & RR1 + 1).Insert Shift:=xlDown
Ws2.Range("A" & RR1 & ":P" & RR1).Copy Destination:=Ws2.Range("A" & RR1 + 1)
Application.CutCopyMode = False
Ws2.Range("I" & RR1 + 1).Value = Ws1.Range("A2").Value
Ws2.Cells(RR1 + 1, 13).Value = CDate(Ws1.Range("B2").Value)
Ws2.Range("J" & RR1 + 1).Value = 0
NewR = RR1
GoTo SaltaNV
End If
End If
Next RR1
SaltaNV:
Next NVR
Next CCA
UR1 = Ws2.Range("B" & Rows.Count).End(xlUp).Row
For RR1 = 8 To UR1
Range("A" & RR1).Value = RR1 - 7
Next RR1
End Sub
Sub TrovaAgg()
Set Ws1 = Worksheets("Archivio")
Set Ws2 = Worksheets("Attuali")
AggS = 0
'Ws2.Range("K8:K1000").ClearContents
For CCA = 3 To 48 Step 5
Dim VNA(90) As Integer
RuA = UCase(Trim(Ws1.Cells(1, CCA)))
For NV = 1 To 90
For Onu = 1 To 5
If NV = Ws1.Cells(2, CCA + Onu - 1).Value Then VNA(Onu) = Ws1.Cells(2, CCA + Onu - 1).Value
Next Onu
Next NV
UR1 = Ws2.Range("B" & Rows.Count).End(xlUp).Row
For RR1 = 8 To UR1 + 30
Ambo = ""
If UCase(Trim(Ws2.Range("B" & RR1).Value)) = UCase(Trim(RuA)) Then
For NV = 1 To 5
For NP = 1 To 5
If VNA(NV) = Ws2.Cells(RR1, 3 + NP).Value Then
Ambo = Ambo & " - " & VNA(NV)
End If
Next NP
Next NV
End If
If Ws2.Cells(RR1, 12).Value < Ws1.Range("A2").Value And Trim(Trim(Ws2.Cells(RR1, 14).Value)) <> "Sto" Then '<<< ULTIMA STRINGA INSERITA
'If Ws2.Cells(RR1, 12).Value < Ws1.Range("A2").Value And Trim(Ws2.Cells(RR1, 12).Value) = "Att" Then '<<< SOSTITUITA STRINGA - If Ws2.Cells(RR1, 12).Value < Ws1.Range("A2").Value Then
AggS = 1
DiffRit = Ws1.Range("A2").Value - Ws2.Cells(RR1, 9).Value
RuA2 = UCase(Trim(Ws2.Range("B" & RR1).Value))
If RuA = RuA2 Then
If Len(Ws2.Cells(RR1, 11).Value) < 5 Then
If Len(Ambo) > 5 Then
Ws2.Cells(RR1, 12).Value = Ws1.Range("A2").Value
Ws2.Cells(RR1, 13).Value = CDate(Ws1.Range("B2").Value)
Ws2.Cells(RR1, 10).Value = DiffRit
Ws2.Cells(RR1, 14).Value = "Sto"
Ws2.Cells(RR1, 11).Value = Trim(Mid(Ambo, 3, Len(Ambo)))
Ws2.Cells(RR1, 16).Value = "Positivo"
Ws2.Cells(RR1, 15).Value = "Ambo"
If Len(Ws2.Cells(RR1, 11).Value) > 8 Then Ws2.Cells(RR1, 15).Value = "Terno"
Rows(RR1 + 1 & ":" & RR1 + 1).Insert Shift:=xlDown
Ws2.Range("A" & RR1 & ":P" & RR1).Copy Destination:=Ws2.Range("A" & RR1 + 1)
Application.CutCopyMode = False
Ws2.Range("K" & RR1 + 1).ClearContents
Ws2.Range("I" & RR1 + 1).Value = Ws1.Range("A2").Value
Ws2.Range("L" & RR1 + 1).Value = Ws1.Range("A2").Value
Ws2.Range("M" & RR1 + 1).Value = CDate(Ws1.Range("B2").Value)
Ws2.Range("J" & RR1 + 1).Value = 0 'DiffRit
Ws2.Range("N" & RR1 + 1).Value = "Att"
Ws2.Range("O" & RR1 + 1).ClearContents
Ws2.Range("P" & RR1 + 1).Value = "in corso"
Ws2.Range("R" & RR1 + 1).Value = 1
Ws2.Range("S" & RR1 + 1).Value = 0
Else
Ws2.Cells(RR1, 10).Value = DiffRit
Ws2.Cells(RR1, 12).Value = Ws1.Range("A2").Value
Ws2.Cells(RR1, 13).Value = CDate(Ws1.Range("B2").Value)
End If
End If
End If
End If
Next RR1
Next CCA
If AggS = 1 Then TrovaSpia
End Sub
Torna a Applicazioni Office Windows
Macro per aprire file salvato su sharepoint Onedrive Autore: marcopont |
Forum: Applicazioni Office Windows Risposte: 2 |
Come interrompere macro sndPlaySound Autore: systemcrack |
Forum: Applicazioni Office Windows Risposte: 2 |
Macro per aggiungere testo in tutti i files di una cartella? Autore: systemcrack |
Forum: Applicazioni Office Windows Risposte: 15 |
Screenshot automatizzato fogli excel:script?macro o...? Autore: Paolo67met |
Forum: Programmazione Risposte: 9 |
Visitano il forum: Nessuno e 17 ospiti