+ Reply to Thread
Results 1 to 2 of 2

Align alike cells in different columns and add blanks where necessary

  1. #1
    Registered User
    Join Date
    06-26-2013
    Location
    Gso
    MS-Off Ver
    Excel 2010
    Posts
    2

    Align alike cells in different columns and add blanks where necessary

    I've included sample data and the code that is so close to working... The code inserts a blank cell in Column B between 150637 & 150639 to align these numbers since 150638 is missing from Column B but present in Column H. I need blank cells in Columns A-F (rather than B only) so that attribute data remains aligned across these rows . I'm hoping for slight modification of code to meet needs. Any help would be appreciated!

    Thanks!
    Kelly

    A B C D E F G H I J
    845 150637 63 845 150637
    846 150639 6.3 846 150638
    847 150644 17.2 847 150639
    848 150645 .99 848 150644

    Sub AlignedSort()

    Dim iRow As Long

    'sort the two columns ascending
    Range("B3", [B65536].End(xlUp)).Sort Key1:=[b1]
    Range("H3", [H65536].End(xlUp)).Sort Key1:=[h1]

    iRow = 2

    Do Until IsEmpty(Cells(iRow, 2)) Or IsEmpty(Cells(iRow, 8))

    If Cells(iRow, 2) < Cells(iRow, 8) Then
    Cells(iRow, 8).Insert xlShiftDown
    ElseIf Cells(iRow, 2) > Cells(iRow, 8) Then
    Cells(iRow, 2).Insert xlShiftDown
    End If

    iRow = iRow + 6

    Loop

    End Sub

  2. #2
    Registered User
    Join Date
    06-26-2013
    Location
    Gso
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Align alike cells in different columns and add blanks where necessary

    Sample worksheets attached, didn't realize my table looked so bad.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1