Bom dia!!
Faça os teste..
Sub test()
Dim dic As Object, i As Long, ii As Long, temp
Dim myLimit As Long, w()
myLimit = Range("h2").Value
Set dic = CreateObject("Scripting.Dictionary")
With Range("h4").CurrentRegion
For ii = 1 To .Columns.Count
For i = 1 To .Rows.Count
temp = .Cells(i, ii).Value
If Not dic.exists(.Cells(i, ii).Value) Then
ReDim w(1)
Set w(0) = .Cells(i, ii)
w(1) = 1
dic(.Cells(i, ii).Value) = w
Else
w = dic(temp)
w(1) = w(1) + 1
If w(1) = myLimit + 1 Then
w(0).ClearContents
End If
Set w(0) = Union(w(0), .Cells(i, ii))
dic(temp) = w
End If
Next
Next
End With
Set dic = Nothing
End Sub
Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel
Postado : 21/04/2012 8:55 am