+ Reply to Thread
Results 1 to 35 of 35

Align Rows - Compare Columns (Issue with shg's alignkeys macro)

  1. #1
    Registered User
    Join Date
    09-05-2013
    Location
    Texas
    MS-Off Ver
    2013
    Posts
    19

    Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Hi All,

    I have a spreadsheet with four columns of data. I'm hoping to align the data in columns AB with CD using A and C as the "keys". I found shg's alignkeys macro and have been trying to use that. Unfortunately, Excel is locking up on me.

    Here's a snippet example:

    2VB3BmI.png

    Any ideas?

    Thanks!

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Hi Massael,

    I wish that you had posted a spreadsheet sample - this is untested, if it works don't blink

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    09-05-2013
    Location
    Texas
    MS-Off Ver
    2013
    Posts
    19

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Thanks xladept - it gives me this error:

    Run-time error 9, subscript out of range.

    It highlights this row:


    If A(i, 1) = "" And C(j, 1) = "" Then GoTo PostAC

  4. #4
    Registered User
    Join Date
    09-05-2013
    Location
    Texas
    MS-Off Ver
    2013
    Posts
    19

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Here's the actual file in zip format:

    http://sdrv.ms/18INgAp

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Hi Massael,

    Try this now:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    09-05-2013
    Location
    Texas
    MS-Off Ver
    2013
    Posts
    19

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Thanks! This worked great!

    Is it possible to write a simple formula that will compare the values in column B and D within a threshold (say 10%) and mark the ones that aren't within that threshold?

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    You're welcome! Yes, we could color the outliers but it would take another pass.

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Hi Massael,

    This will color the outliers red as well as the records with zero as a sum - it can only be run once,not twice and that's been driving me crazy - let me know if you like it:

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    09-05-2013
    Location
    Texas
    MS-Off Ver
    2013
    Posts
    19

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Awesome. Thank you so very much for your help!

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Hi Massael,

    My Internet was down for two days as I changed ISP's. I fancied up the program a little more and made it so that you can run it over and over if you want - The columns A and C were in different formats:

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    09-05-2013
    Location
    Texas
    MS-Off Ver
    2013
    Posts
    19

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Thank you for the updated code. I actually just tried to re-run this with a new dataset and received the same error code as before, Run-time error 9.

    I've attached the file in case it's an issue with the file itself. https://dl.dropboxusercontent.com/u/...ata-macro.xlsm

  12. #12
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Hi Massael,

    We've got overflow - try this:

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    09-05-2013
    Location
    Texas
    MS-Off Ver
    2013
    Posts
    19

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    That worked great, thank you!

  14. #14
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Wonderful!

  15. #15
    Registered User
    Join Date
    09-05-2013
    Location
    Texas
    MS-Off Ver
    2013
    Posts
    19

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Apparently I exist to confound you - so once again I am going to ask for a little help!

    It seems that the data is not aligning as expected when I run the macro. I've included the file with macro. I would really appreciate it if you could take a look.

    https://dl.dropboxusercontent.com/u/...data-help.xlsm

  16. #16
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Seems no matched row in your file.

    Try this
    Please Login or Register  to view this content.

  17. #17
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Hi Massael,

    Jindon writes very good code but I think the problem may be in the data - we've got to "scrub" it somehow, but I haven't yet figured it out

  18. #18
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Hi Massael,

    This is what I'm trying:

    Please Login or Register  to view this content.
    (I figured it out)
    Last edited by xladept; 10-19-2013 at 08:00 PM.

  19. #19
    Registered User
    Join Date
    09-05-2013
    Location
    Texas
    MS-Off Ver
    2013
    Posts
    19

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    xladept,

    It seems some data wasn't being handled (spaces, leading zeroes), so I scrubbed those. Now the macro doesn't work.

    Here's the file after cleaning the data up:

    https://dl.dropboxusercontent.com/u/...data-help.xlsm

  20. #20
    Registered User
    Join Date
    09-05-2013
    Location
    Texas
    MS-Off Ver
    2013
    Posts
    19

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Quote Originally Posted by jindon View Post
    Seems no matched row in your file.

    Try this
    Please Login or Register  to view this content.
    jindon,

    Your code runs after I cleaned the data up and finds matches, however I lose a lot of data in the C,D columns. Any idea why?

  21. #21
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Hi Massael,

    Did you incorporate my scrub program as in the last posting - it ran nicely for me??

    Also, it is paramount that this line read like this:

    Please Login or Register  to view this content.
    Last edited by xladept; 10-21-2013 at 05:27 PM.

  22. #22
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Hi Massael,

    I am confounded - I've asked other members for help on this.
    Last edited by xladept; 10-21-2013 at 08:15 PM.

  23. #23
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Quote Originally Posted by Massael View Post
    jindon,

    Your code runs after I cleaned the data up and finds matches, however I lose a lot of data in the C,D columns. Any idea why?
    Have you checked col.C,D further down?

    Unmatched data will line up below the end of col.A,B.

    Otherwise, need to see your cleaned up file.

  24. #24
    Registered User
    Join Date
    09-05-2013
    Location
    Texas
    MS-Off Ver
    2013
    Posts
    19

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Quote Originally Posted by jindon View Post
    Have you checked col.C,D further down?

    Unmatched data will line up below the end of col.A,B.

    Otherwise, need to see your cleaned up file.
    Jindon,

    It seems to reduce the record count from 58,000 in Col C,D down to 22,000.

    Original data pre-macro:
    https://dl.dropboxusercontent.com/u/...data-help.xlsm

    Here's the file post macro:
    https://dl.dropboxusercontent.com/u/...ata-help2.xlsm

  25. #25
    Registered User
    Join Date
    09-05-2013
    Location
    Texas
    MS-Off Ver
    2013
    Posts
    19

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    xladept,

    Thank you - I realize this is strange. I'm not sure why the overflow is occurring. As i'm relatively familiar with scrubbing data, I did that myself, so it's now clear. After doing that - suddenly the macro no longer runs. Sorry this is so troublesome, I truly appreciate your help.

  26. #26
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    I just run the code on the file you last provided and the amount of the rows are the same.

    Before
    Col.A has 58683 rows
    Col.C has 59749 rows

    and the result has the same with matched rows are lined up and end up with 82238 rows.

    P.S
    And the result file you attached was not from my code.
    Last edited by jindon; 10-22-2013 at 08:21 AM.

  27. #27
    Registered User
    Join Date
    09-05-2013
    Location
    Texas
    MS-Off Ver
    2013
    Posts
    19

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    I'm not seeing that result - wondering why my macro is working differently...

    The second file I attached is after running your macro, and I have 21229 rows in columns C&D. I'm running Excel 2013 if that makes a difference. Is there a special method to executing the macro?

  28. #28
    Registered User
    Join Date
    09-05-2013
    Location
    Texas
    MS-Off Ver
    2013
    Posts
    19

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    To note, we know there are a few thousand that don't match - ~6-10,000 - but not 30,000+

  29. #29
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    OOOps, terribly sorry, I think I gave you the one before I have edited.

    The last line should read as
    Please Login or Register  to view this content.

  30. #30
    Registered User
    Join Date
    09-05-2013
    Location
    Texas
    MS-Off Ver
    2013
    Posts
    19

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    The data is all there now, however not matching properly. Example value:

    120062001

    Is in cells C58777 and also cell A101 but not aligned. Any idea why? I really appreciate the help.

  31. #31
    Registered User
    Join Date
    09-05-2013
    Location
    Texas
    MS-Off Ver
    2013
    Posts
    19

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Looking at this more, seems it's a Text/Number issue as there's alphanumeric data. Any way to account for this?

  32. #32
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    OK, that's because of the difference of data types.
    Try this one
    Please Login or Register  to view this content.

  33. #33
    Registered User
    Join Date
    09-05-2013
    Location
    Texas
    MS-Off Ver
    2013
    Posts
    19

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Perfect! Thank you!!!!

  34. #34
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Glad it worked.

    Can you mark this thread as "Solved"?

  35. #35
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Align Rows - Compare Columns (Issue with shg's alignkeys macro)

    Hi Massael,

    I'm still confounded but I've added that percentage routine to Jindon's code:

    Please Login or Register  to view this content.

+ 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. Need to compare 2 columns and align them next to the match
    By naenightlucky213 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-09-2013, 06:14 AM
  2. [SOLVED] Compare and align rows of multiple but differing columns of data
    By e abor in forum Excel General
    Replies: 0
    Last Post: 06-06-2006, 12:10 PM
  3. [SOLVED] Compare and align columns of data
    By JGouger in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-11-2005, 12:30 PM
  4. Macro to align & compare multiple columns with several rows
    By Manav Ram via OfficeKB.com in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-07-2005, 04:10 PM
  5. Macro to align and compare multiple rows and columns
    By Manav Ram via OfficeKB.com in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 03-04-2005, 09:06 PM

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