+ Reply to Thread
Results 1 to 3 of 3

VBA script to match rows with blanks and move entire rows.

  1. #1
    Registered User
    Join Date
    05-18-2016
    Location
    Guatemala city, Guatemala
    MS-Off Ver
    2010
    Posts
    2

    VBA script to match rows with blanks and move entire rows.

    Hello everyone, I am barely new here and I registered because I am desperate as I cannot find out the way to get a macro to work properly.

    I would like to know if there is someone who can help me out with this.

    I have two data tables like this

    (I used dashes to delimitate the two tables because it does not allow me to do it in another way )

    column A = code
    column B = type
    column C = price

    STORE A ---STORE B
    A B C ---A B C

    1 A 5 ---1 B 3
    1 B 4 ---1 A 5
    2 A 3 ---2 A 4
    3 A 3 ---3 A 3
    4 A 4 ---4 A 4
    4 B 2 ---4 B 3
    5 A 3 ---6 B 3
    7 A 3 ---6 A 5
    7 B 2 ---* * *


    And I would like to get a VBA script to compare the two tables and align the entire row based on code and type. so I can get something like this.

    STORE A ---STORE B

    A B C ---A B C

    1 A 5 ---1 A 5
    1 B 4 ---1 B 3
    2 A 3 ---2 A 4
    3 A 3 ---3 A 3
    4 A 4 ---4 A 4
    4 B 2 ---4 B 3
    5 A 3 ---* * *
    * * * ---6 B 3
    * * * ---6 A 5
    7 A 3 ---* * *
    7 B 2 ---* * *

    There was someone who could make it in this forum ( http://www.mrexcel.com/forum/excel-q...ta-blanks.html ) however that VBA only aligns one cell and I need to align the entire row.

    Is anybody out there who can help me out, I would be eternally grateful.

    Thanks!.
    Last edited by Aleksito; 05-25-2016 at 09:13 AM.

  2. #2
    Registered User
    Join Date
    02-14-2013
    Location
    Dallas TX
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: VBA script to match rows with blanks and move entire rows.

    Where is the code for the row. We dont usually want to build something scratch?

  3. #3
    Registered User
    Join Date
    05-18-2016
    Location
    Guatemala city, Guatemala
    MS-Off Ver
    2010
    Posts
    2

    Re: VBA script to match rows with blanks and move entire rows.

    I was using this one.

    It just matches the code columns (A and E), the other columns (B,C,F,G) remain in the same position I would like the macro would work for the whole columns in each row not only the code column.

    Sub matchemup()
    Dim n As Long, a As Range, c As Range, x As Long
    n = Cells.SpecialCells(11).Row
    Set a = Range("A:A"): Set c = Range("E:E")
    a(n + 1) = Chr(255): c(n + 1) = Chr(255)
    a.Sort a(1), 1, header:=xlNo
    c.Sort c(1), 1, header:=xlNo
    Do
    x = x + 1
    If a(x) > c(x) Then
    a(x).Insert xlDown
    ElseIf a(x) < c(x) Then
    c(x).Insert xlDown
    End If
    If x > 10 ^ 4 Then Exit Do
    Loop Until a(x) = Chr(255) And c(x) = Chr(255)
    a(x).ClearContents: c(x).ClearContents
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Move Entire Rows to Archive Worksheet
    By LBinGA in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 01-02-2016, 08:05 PM
  2. [SOLVED] Move entire row to other sheet without inserting new rows
    By ALNER in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-15-2014, 10:48 AM
  3. [SOLVED] Help: Need VBA script to remove rows if a column field doesn't match a certain length.
    By rmconard in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-08-2013, 04:04 PM
  4. [SOLVED] Macros To Move Multiple Rows To Another Sheet And Macro To Move Single Rows To DAX Table
    By jcaynes in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-22-2013, 05:08 PM
  5. [SOLVED] How to move entire rows if a condition is met
    By mcculltc in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-12-2013, 03:46 PM
  6. [SOLVED] Insert and Delete blanks rows so that there are 2 blanks rows between text rows
    By erniedawg in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-29-2013, 02:27 AM
  7. [SOLVED] Move data in rows ignoring blanks
    By mmartin79 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-25-2012, 10:16 AM

Tags for this Thread

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