- Codice: Seleziona tutto
Public RRA, URAF As Integer, ValC As String
Sub CompilaArmatura()
URA = Worksheets("Armatura").Range("G" & Rows.Count).End(xlUp).Row
URF = Worksheets("File txt").Range("F" & Rows.Count).End(xlUp).Row
URAF = Worksheets("Archivio Ferri").Range("C" & Rows.Count).End(xlUp).Row
Worksheets("Armatura").Range("F12:F108").Delete Shift:=xlUp
MValC = ""
For RRA = 13 To URA
ValC = Worksheets("Armatura").Range("G" & RRA).Value
If ValC = "" Then
PrV = 0
GoTo SaltaRRA
End If
For RRF = 3 To URF
ValF = Worksheets("File Txt").Range("F" & RRF).Value
ValFE = Worksheets("File Txt").Range("E" & RRF).Value
ValFB = Worksheets("File Txt").Range("B" & RRF).Value
If ValF = "" Then GoTo SaltaRRF
If ValC = ValF Then
Tr = 0
If PrV = 0 Then
Righe = Worksheets("Armatura").Range("G" & RRA).CurrentRegion.Rows.Count
IniR = RRA
PrV = 1
Worksheets("Armatura").Range("B" & IniR & ":D" & IniR - 1 + Righe).ClearContents
End If
For RRFC = IniR To IniR - 1 + Righe
ValCC = Worksheets("Armatura").Range("C" & RRFC).Value
ValCD = Worksheets("Armatura").Range("D" & RRFC).Value
If ValCC = ValFE And ValCD = ValFB Then Tr = 1
Next RRFC
End If
If ValC = ValF And Tr = 0 Then
Worksheets("Armatura").Range("B" & RRA).Value = Worksheets("File Txt").Range("D" & RRF).Value
Worksheets("Armatura").Range("C" & RRA).Value = Worksheets("File Txt").Range("E" & RRF).Value
Worksheets("Armatura").Range("D" & RRA).Value = Worksheets("File Txt").Range("B" & RRF).Value
Call ComFerri
GoTo SaltaRRA
End If
SaltaRRF:
Next RRF
SaltaRRA:
Next RRA
End Sub
Private Sub ComFerri()
For RAF = 3 To URAF
ValAF = Worksheets("Archivio Ferri").Range("C" & RAF).Value
If ValAF = "" Then GoTo SaltaRAF
If ValC = ValAF Then
Worksheets("Archivio Ferri").Range("B" & RAF).Copy Destination:=Worksheets("Armatura").Range("F" & RRA)
Exit Sub
End If
SaltaRAF:
Next RAF
End Sub
e avvia CompilaArmatura
La macro non fa uso di UserForm, quindi puoi eliminarlo, elimina anche il codice nel foglio Armature (Worksheet_BeforeDoubleClick) e il modulo2, se non l'hai utilizzato per questa macro
La tabella "T" non viene compilata solo perché nei dati non esiste questo codice
Fai sapere se tutto ok
Ciao