+ Reply to Thread
Results 1 to 7 of 7

Need Macro to Compare Columns and then Reorganize Rows

  1. #1
    Registered User
    Join Date
    09-09-2011
    Location
    Arizona, United States
    MS-Off Ver
    Excel 2007
    Posts
    19

    Need Macro to Compare Columns and then Reorganize Rows

    I have this spreadsheet where I am trying to get a macro to compare column b with a and if they match, to move column b under column a to reorganize a gigantic spreadsheet. Any ideas?

    I have an example attached
    Attached Files Attached Files
    Last edited by WildSpreadsheets; 09-12-2011 at 09:50 PM.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,219

    Re: Sophisticated macro that organizes rows based on column values

    Hi WildSpreadsheets and welcome to the forum,

    I guess I need a sample workbook to play with to understand this problem.
    Looking at your example, Column B would be copied under column A twice for Eggs and one more time as it has a Juice in it. Do you use all/any value in column A to match any value in Column B to decide if to copy it?

    You can attach a sample by clicking on "Go Advanced" below the message area and then on the Paper Clip Icon above the advanced message area.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    09-09-2011
    Location
    Arizona, United States
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Sophisticated macro that organizes rows based on column values

    Hi MarvinP!

    Thank you for your quick reply! Sorry for my late follow-up ... I have created a better example for you to look at in my excel spreadsheet to give you the exact idea I have in mind.

    I want the macro to reorganize the jumbled example on the left and make it look like the one on the right.

    Sorry for all of the messy explanations.. I tried to explain it the best I can and it is a problem that is kind of hard to explain!

    Thank you for your help!
    Attached Files Attached Files

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,219

    Re: Sophisticated macro that organizes rows based on column values

    Hi WildSpreadsheets,

    Your question is close to a relational database sorting method. Parent and Child relationships are needed to solve your problem. Look at sheet 2 where I've added a d'Aboville System to your data and sorted it accordingly. See http://en.wikipedia.org/wiki/Genealo...bering_systems for styles of numbering.

    In short I have no idea how to build the numbering system on sheet 2 column A using Excel on the attached.

    Maybe one of the smart Guru's can figure it out. I'll think about it a while but this might be a problem Excel isn't well suited to do.

    Maybe that is why you've named yourself WildSpreadsheets?
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    09-09-2011
    Location
    Arizona, United States
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Sophisticated macro that organizes rows based on column values

    Hi MarvinP!

    I thought about using that numbering system as well so that I can just sort things in order. This works for a shorter list of data that is constant and manually managed

    My only problem is that every week my spreadsheet contains randomly pulled data that is unorganized, so I cannot use the same numbering system. Which poses the problem that you stated, which is figuring out how to build the numbering system for the random parent/child-matching of data so that it can be sorted accordingly.

    I am dealing with about a thousand "Parents" with multiple "Child" relationships which go as deep as 7 levels.

    This is exactly why I go by WildSpreadsheets!...

  6. #6
    Registered User
    Join Date
    09-09-2011
    Location
    Arizona, United States
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Need Macro to Compare Columns and then Reorganize Rows

    I may be making this sound more complicated than it really is. Can a Macro just compare two columns and then move the entire rows under the matching columns accordingly?

  7. #7
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,219

    Re: Need Macro to Compare Columns and then Reorganize Rows

    It is true that this problem may be easier than we think. The problem is, we're not thinking those simple thoughts.

    I've pondered this answer about 5 times in the last few days without a good answer. If we knew who the first parent was it might be easier. It seems to me it has to be determined from simply having two colums of names (foods in your case) and building the tree from them.

    I am sorry I don't have a good answer, yet.

    Lets see if any other gurus weigh in and have an answer.

+ 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