
Sub ORDINI_TS()
'
' ORDINI_TS Macro
'
Dim i As Long, j As Long
Dim valAB As Long
Dim F1 As String, F2 As String
F1 = Sheets(1).Name
F2 = Sheets(3).Name
' Il contatore "i" serve per selezionare gli ordini del foglio2
For i = 6 To 10
' Il contatore "j" serve per confrontare gli ordini gli ordini del foglio1
For j = 2 To 6 + i
' valAB = Sheets(F1).Cells(1, i)
If Sheets(F3).Cells(i, 3) <= Sheets(F1).Cells(j, 3) Then
Sheets(F1).Activate
ActiveSheet.Range("J:J").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Sheets(F3).Activate
ActiveSheet.Range(Cells(i, 3)).Select
Selection.Copy
Sheets(F1).Activate
ActiveSheet.Cells(j, 3).Select
ActiveSheet.Paste
Sheets(F3).Activate
ActiveSheet.Range(Cells(i, 7)).Select
Selection.Copy
Sheets(F1).Activate
ActiveSheet.Cells(j, 5).Select
ActiveSheet.Paste
End If
If Sheets(F3).Cells(i, 3) > Sheets(F1).Cells(j, 3) Then
Sheets(F1).Activate
ActiveSheet.Range("J+1:J+1").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Sheets(F3).Activate
ActiveSheet.Range(Cells(i, 3)).Select
Selection.Copy
Sheets(F1).Activate
ActiveSheet.Cells(j, 3).Select
ActiveSheet.Paste
Sheets(F3).Activate
ActiveSheet.Range(Cells(i, 7)).Select
Selection.Copy
Sheets(F1).Activate
ActiveSheet.Cells(j, 5).Select
ActiveSheet.Paste
End If
Next j
Next i
End Sub
|
Sub CopiaDa_F3_a_F1()
Dim i As Long, j As Long
Dim valD_F1 As Long
Dim F1 As String, F2 As String
F1 = Sheets(1).Name
F3 = Sheets(3).Name
For i = 2 To Sheets(F1).Cells(Rows.Count, "C").End(xlUp).Row
valD_F1 = Sheets(F1).Cells(i, "C")
For j = 6 To Sheets(F3).Cells(Rows.Count, "C").End(xlUp).Row
If valD_F1 = Sheets(F3).Cells(j, "C") Then
Sheets(F1).Cells(i, "E") = Sheets(F3).Cells(j, "G")
Exit For
End If
Next j
Next i
End Sub
|
Sub Insert_F3_a_F1()
Dim i As Long, j As Long
Dim valD_F3 As Long
Dim F1 As String, F2 As String
F1 = Sheets(1).Name
F3 = Sheets(3).Name
For i = 6 To Sheets(F3).Cells(Rows.Count, "C").End(xlUp).Row Step 2
valD_F3 = Sheets(F3).Cells(i, "C")
For j = 2 To Sheets(F1).Cells(Rows.Count, "C").End(xlUp).Row
If valD_F3 <= Sheets(F1).Cells(j, "C") Then
Sheets(F1).Range(j & ":" & j).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Sheets(F1).Cells(j, "C") = Sheets(F3).Cells(i, "C")
Sheets(F1).Cells(j, "E") = Sheets(F3).Cells(i, "G")
Exit For
End If
Next j
Next i
End Sub |
rigafine = 23 For i = 6 To rigafine Step 2 |
