Una famiglia di software per fogli di calcolo Microsoft con strumenti per l'analisi, la creazione di grafici e la comunicazione dei dati.
Ciao Norman
funziona perfettamente. Per completare al meglio , ora devo rimuovere le righe uguali ;
- l' intervallo di selezione va da B12 a P (intera colonna);
- mentre la colonna contenente i duplicati è la E
Grazie
Ciao Zulu,
Penso che questa sia una domanda separata e distinta; l'unico vero nesso che posso vedere è che entrambe le domande si riferiscono alla stessa cartella di lavoro. Posterò una soluzione a condizione che, in futuro, cercherai di aprire un thread separato per ogni domanda. Questo ti aiuterà, perché è probabile che riceverai più risposte utili e aiuterà anche chi avra bisogno di cercare negli archivi del forum per una soluzione a un problema simile.
A lavoro!
Alt-F11 per aprire l'editor di VBA
Alt-IM per inserire un nuovo modulo di codice
Nel nuovo modulo vuoto, incolla il seguente codice:
'========>>
Option Explicit
'-------->>
Public Sub DeleteRange()
Dim WB As Workbook
Dim SH As Worksheet
Dim Rng As Range
Dim rCell As Range
Dim delRng As Range
Dim iLastRow As Long
Dim oDic As Object
Dim CalcMode As Long
On Error GoTo ErrHandler
Set WB = ThisWorkbook
Set SH = WB.Sheets("QTR")
With SH
iLastRow = SH.Cells(Rows.Count, "A").End(xlUp).Row
Set Rng = SH.Range("E12:E" & iLastRow)
End With
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
Set oDic = CreateObject("Scripting.Dictionary")
oDic.CompareMode = vbTextCompare
For Each rCell In Rng.Cells
With rCell
If Not oDic.exists(.Value) Then
oDic.Add Key:=.Value, Item:=.Value
Else
If delRng Is Nothing Then
Set delRng = rCell
Else
Set delRng = Union(rCell, delRng)
End If
End If
End With
Next rCell
If Not delRng Is Nothing Then
Intersect(delRng.EntireRow, SH.Columns("B:P")).Delete Shift:=xlUp
Else
'nothing found, do nothing
End If
XIT:
With Application
.Calculation = CalcMode
.ScreenUpdating = True
End With
On Error GoTo 0
Exit Sub
ErrHandler:
Call MsgBox(Prompt:="Error " _
& Err.Number _
& " (" _
& Err.Description _
& ") nella routine: DeleteRange", _
Buttons:=vbCritical, _
Title:="ERRORE")
Resume XIT
End Sub
'-------->>
Function LastRow(SH As Worksheet, _
Optional Rng As Range)
If Rng Is Nothing Then
Set Rng = SH.Cells
End If
On Error Resume Next
LastRow = Rng.Find(What:="*", _
After:=Rng.Cells(1), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function
'<<========
Alt-Q per chiudere l'editor di VBA
Alt-F8 per aprire la finestrina macro
Seleziona DeleteRange | Esegui
===
Regards,
Norman