Sub ArranjaDadosV2()
Dim a As Long, k As Long, m As Long, x As Long, rng(), LR As Long, LC As Long
LR = ActiveSheet.UsedRange.Find(what:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
LC = ActiveSheet.UsedRange.Find(what:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByColumns).Column
Sheets("Plan2").Range("A4:C" & Cells(Rows.Count, 1).End(3).Row) = ""
For a = 2 To LR
On Error GoTo gko
k = Application.CountA(Cells(a, 1).Offset(, 1).Resize(, LC))
Sheets("Plan2").Cells(m + 4, 1).Resize(k) = Cells(a, 1)
For x = 1 To LC
If Cells(a, 1).Offset(, x) <> "" Then
rng = Array(Cells(1, x + 1), Cells(a, x + 1))
Sheets("Plan2").Cells(m + 4, 2).Resize(, 2).Value = rng
m = m + 1
End If
Next x
gko:
Resume Next
Next a
End Sub
Postado : 30/05/2016 5:48 pm