Results 1 to 12 of 12

Thread: Move data in columns to align them at the bottom

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #9
    VBAX Contributor
    Joined
    Jul 2005
    Posts
    195
    Location
    Another one, should be very fast...
    Sub test()
        Dim a, i&, ii&, iii As Long, n&
        With Columns(1).SpecialCells(2).Areas(1).CurrentRegion
            a = .Value2
            For ii = 1 To UBound(a, 2)
                n = 0: iii = 0
                For i = UBound(a, 1) To 1 Step -1
                    If a(i, ii) = "" Then
                        n = n + 1
                    Else
                        Exit For
                    End If
                Next
                If n Then
                    For i = UBound(a, 1) - n To 1 Step -1
                        a(UBound(a, 1) - iii, ii) = a(i, ii)
                        iii = iii + 1
                        If i <= n Then a(i, ii) = ""
                    Next
                End If
            Next
            .Value2 = a
        End With
    End Sub
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •