
Sub Salva_PULIZIA()
' Salva_PULIZIA Macro
Dim rngdati As Range, rng As Range, cella As Range
Dim data(28), col(28)
Dim c As Integer, diff As Integer, riga As Integer
Application.ScreenUpdating = False
For c = 1 To 28
Cells(1, c + 28).Select
data(c) = CDate(Cells(1, c + 28))
Next c
Set rngdati = Range("ac2:bd" & Cells(Rows.Count, 2).End(xlUp).Row)
With Sheets("PULIZIA")
Set rng = .Range(.[h2], .Cells(2, .[h2].CurrentRegion.Columns.Count))
For Each cella In rng
For c = 1 To 28
If cella.Value = data(c) Then
col(c) = cella.Column
End If
Next c
Next
For c = 1 To 28
diff = -2 - c
If cella <> "" Then
On Error Resume Next
riga = .Columns(1).Find(cella.Offset(, diff).Value, LookIn:=xlValues).Row
.Cells(riga, col(c)) = cella.Value
End If
Next
Next c
End With
MsgBox "Inserimento effettuato"
Application.ScreenUpdating = True
End Sub
|
Sub Salva_Pulizia()
Dim rngdati As Range, rng As Range, cella As Range
Dim data(28), col(28)
Dim c As Integer, diff As Integer, riga As Integer
Application.ScreenUpdating = False
For c = 1 To 28
Cells(1, c + 28).Select
data(c) = CDate(Cells(1, c + 28))
Next c
Set rngdati = Range("ac2:bd" & Cells(Rows.Count, 2).End(xlUp).Row)
With Sheets("PULIZIA")
Set rng = .Range(.[h2], .Cells(2, .[h2].CurrentRegion.Columns.Count))
For Each cella In rng
For c = 1 To 28
If cella.Value = data(c) Then
col(c) = cella.Column
End If
Next c
Next
For c = 1 To 28
diff = -2 - c
For Each cella In rngdati.Columns(c).Cells
If cella <> "" Then
On Error Resume Next
riga = .Columns(1).Find(cella.Offset(, diff).Value, LookIn:=xlValues).Row
.Cells(riga, col(c)) = cella.Value
End If
Next
Next c
End With
MsgBox "Inserimento effettuato"
Application.ScreenUpdating = True
End Sub |
