Skip to content

Instantly share code, notes, and snippets.

@TGDUY

TGDUY/Loc.bas

Created May 14, 2018
Embed
What would you like to do?
Sub Loc()
Dim DATA As Variant, I As Long, J As Long, TMP As Variant, MA As String, T As Double
DATA = Sheet1.Range("A2:C" & Sheet1.Cells(Sheet1.Rows.Count, "C").End(xlUp).Row).Value2
T = Timer
ReDim TMP(1 To 3, 1 To 1)
For I = 1 To UBound(DATA, 1)
MA = CStr(DATA(I, 1) & DATA(I, 2))
If MA <> vbNullString Then
J = J + 1
ReDim Preserve TMP(1 To 3, 1 To J)
TMP(1, J) = DATA(I, 1)
TMP(2, J) = DATA(I, 2)
TMP(3, J) = DATA(I, 3)
Else
TMP(3, J) = TMP(3, J) & " ; " & DATA(I, 3)
End If
Next
Sheet2.Range("A2:C1048576").ClearContents
Sheet2.Range("A2").Resize(UBound(TMP, 2), 3) = Application.Transpose(TMP)
MsgBox Round(Timer - T, 3)
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment