
Sub cv()
On Error GoTo AVANTI
Dim i As Integer
dim nc as string
For i = 1389 To 1 step -1
nc = Application.WorksheetFunction.VLookup(Cells(i, 6),Workbooks("FileB").Worksheets("report").Range(Cells(2, 2), Cells(5987, 2)), 1, False)
Cells(i, 6).EntireRow.Delete
Next
AVANTI:
i = i - 1
Resume Next
End Sub |
Sub tttest()
Dim R1 As Range, R2 As Range
Dim C As Long
With Workbooks("FileB").Worksheets("report")
Set R1 = .Range(.Cells(2, 2), .Cells(5987, 2))
End With
For C = 1389 To 1 Step -1
Set R2 = R1.Find(Cells(C, 6))
If Not R2 Is Nothing Then Cells(C, 6).EntireRow.Delete
Next C
End Sub |
'1)
Workbooks.Open("FileB") ' apre FileB
'ATTENZIONE, dopo l'esecuzione di questa istruzione, il Workbook attivo è quello di FileB
'Per rendere di nuovo attivo il Workbook che contiene la macro usare
ThisWorkbook.Activate ' altrimenti la macro non funziona correttamente
'Puoi chiudere il file precedentemente aperto con
Workbooks("FileB").Close
'2)
With Sheets("Foglio1")
.Range("A1")
End With
'Equivalente a
Sheets("Foglio1").Range("A1")
|
Sub tttest()
Dim R1 As Range, R2 As Range
Dim C As Long
Workbooks.Open ("C:UsersambrogioDesktopNuova cartellamacroFile") ' funziona
With Workbooks("File").Worksheets("report")
Set R1 = .Range(.Cells(2, 2), .Cells(5987, 2))
End With
ThisWorkbook.Activate
For C = 1389 To 1 Step -1
Set R2 = R1.Find(Cells(C, 6))
If Not R2 Is Nothing Then Cells(C, 6).EntireRow.Delete
Next C
Workbooks("C:UsersambrogioDesktopNuova cartellamacroFile").Close 'dà errore ovunque lo metta
End Sub |
