Moderatori: Anthony47, Flash30005
For Each cc1 In rng1
manca = True
For Each cc2 In rng2
If cc1.Value = cc2.Value Then
manca = False
cc1.Offset(, 8).Resize(, 3).Value = cc1.Resize(, 3).Value
Exit For
End If
Next
If manca Then cc1.Offset(, 14).Resize(, 3).Value _
= cc1.Resize(, 3).Value
Next
For Each cc1 In rng1
If Application.WorksheetFunction.CountIf(rng2, cc1.Value) > 0 Then
cc1.Offset(, 8).Resize(, 3).Value = cc1.Resize(, 3).Value
Else
cc1.Offset(, 14).Resize(, 3).Value = cc1.Resize(, 3).Value
End If
Next
ma io non trovo la stringa da modificare... unisco il codice corretto:A parte la velocita', la macro precedente non considera uguali stringhe minuscolo e stringhe maiuscole, quindi ad esempio ABITARE SEGESTA e Abitare Segesta sono considerati diversi. Per evitare cio' potresti sostituire If cc1.Value = cc2.Value Then con If UCase(cc1.Value) =UCase(cc2.Value) Then
Sub seleziona()
Dim rng1 As Range, rng2 As Range
Dim cc1 As Range, cc2 As Range
Dim manca As Boolean, alt As Long
Application.Calculation = xlManual
Application.ScreenUpdating = False
Set rng1 = Worksheets("Foglio1").Range("A2")
With rng1.Offset(-1, 8).Resize(, 3)
.HorizontalAlignment = xlCenter
.MergeCells = True
.Value = "In A e anche in D"
End With
With rng1.Offset(-1, 14).Resize(, 3)
.HorizontalAlignment = xlCenter
.MergeCells = True
.Value = "In A ma non in D"
End With
Set rng1 = rng1.Resize(rng1.End(xlDown).Row - rng1.Row + 1)
Set rng2 = Worksheets("Foglio1").Range("D2")
With rng2.Offset(-1, 8).Resize(, 3)
.HorizontalAlignment = xlCenter
.MergeCells = True
.Value = "In D e anche in A"
End With
With rng2.Offset(-1, 14).Resize(, 3)
.HorizontalAlignment = xlCenter
.MergeCells = True
.Value = "In D ma non in A"
End With
Set rng2 = rng2.Resize(rng2.End(xlDown).Row - rng2.Row + 1)
For alt = 0 To 1
If alt Then
Set cc1 = rng1
Set rng1 = rng2
Set rng2 = cc1
End If
For Each cc1 In rng1
If Application.WorksheetFunction.CountIf(rng2, cc1.Value) > 0 Then
cc1.Offset(, 8).Resize(, 3).Value = cc1.Resize(, 3).Value
Else
cc1.Offset(, 14).Resize(, 3).Value = cc1.Resize(, 3).Value
End If
Next
Next
rng1.Offset(, 8).Resize(, 3).Sort _
Key1:=rng1.Offset(, 8).Resize(1, 1), _
Order1:=xlAscending, _
Header:=xlNo, _
MatchCase:=False, _
Orientation:=xlTopToBottom
rng1.Offset(, 14).Resize(, 3).Sort _
Key1:=rng1.Offset(, 14).Resize(1, 1), _
Order1:=xlAscending, _
Header:=xlNo, _
MatchCase:=False, _
Orientation:=xlTopToBottom
rng2.Offset(, 8).Resize(, 3).Sort _
Key1:=rng2.Offset(, 8).Resize(1, 1), _
Order1:=xlAscending, _
Header:=xlNo, _
MatchCase:=False, _
Orientation:=xlTopToBottom
rng2.Offset(, 14).Resize(, 3).Sort _
Key1:=rng2.Offset(, 14).Resize(1, 1), _
Order1:=xlAscending, _
Header:=xlNo, _
MatchCase:=False, _
Orientation:=xlTopToBottom
Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
End Sub
Questo commento era riferito alla macro tua originale, e l' ho inserito per dare una giustificazione alle anomalie sui risultati di cui tu parlavi.A parte la velocita', la macro precedente non considera uguali stringhe minuscolo e stringhe maiuscole, quindi ad esempio ABITARE SEGESTA e Abitare Segesta sono considerati diversi.
Torna a Applicazioni Office Windows
Macro modifica date scelta periodo Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 11 |
Supporto per sviluppo macro VBA Ordinare per data Autore: Carletto Ribolla |
Forum: Applicazioni Office Windows Risposte: 3 |
Macro per aprire file salvato su sharepoint Onedrive Autore: marcopont |
Forum: Applicazioni Office Windows Risposte: 2 |
Come interrompere macro sndPlaySound Autore: systemcrack |
Forum: Applicazioni Office Windows Risposte: 2 |
Visitano il forum: Nessuno e 8 ospiti