+ Reply to Thread
Results 1 to 17 of 17

Compare Sheets and sort columns based on sheet 3

  1. #1
    Registered User
    Join Date
    12-21-2014
    Location
    chennai
    MS-Off Ver
    2010
    Posts
    37

    Compare Sheets and sort columns based on sheet 3

    Hi Team,

    PFA my sample document. Here,

    I Need to compare TD sheet with DB2 and make sure we have the same order of columns present in TD Sheet, if not then need to sort it according to DB2 sheet.

    Thanks
    Anand R
    Attached Files Attached Files

  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: Compare Sheets and sort columns based on sheet 3

    Hi Anand,

    Try this:

    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
    12-21-2014
    Location
    chennai
    MS-Off Ver
    2010
    Posts
    37

    Re: Compare Sheets and sort columns based on sheet 3

    Hi

    Thanks for the reply.

    I ran your code it is working fine but my scenario is that

    a) Check the order of columns are placed (present) in DB Sheet
    b) if the order of columns are placed differently in TD sheet, then place as in DB sheet (order like in DB Sheet)
    c) And sort the DB and TD sheet by column wise

    Regards,
    Anand R

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

    Re: Compare Sheets and sort columns based on sheet 3

    Hi Anand,

    My program yields exactly the same output as in your example - can you post a different example?

    I changed the headers

    Please Login or Register  to view this content.
    Last edited by xladept; 02-02-2015 at 04:16 PM.

  5. #5
    Registered User
    Join Date
    12-21-2014
    Location
    chennai
    MS-Off Ver
    2010
    Posts
    37

    Re: Compare Sheets and sort columns based on sheet 3

    Hi,

    I ran you code in my local.

    You are writing TRUE values in Compared Sheet. But I write cells values (not true / false values) in TD sheet which is different order from DB sheet.
    And Sort column wise for the both Sheet.

    Thanks
    Anand R

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

    Re: Compare Sheets and sort columns based on sheet 3

    Can you post an example illustrating what you need?

  7. #7
    Registered User
    Join Date
    12-21-2014
    Location
    chennai
    MS-Off Ver
    2010
    Posts
    37

    Re: Compare Sheets and sort columns based on sheet 3

    Hi,

    Please find my 2 sample document -- one is input and other is output which i need after running the macro.

    My requirement is :

    a) Check the order of columns are placed (present) in DB Sheet
    b) Check if the order of columns are placed differently in TD sheet, then place as in DB sheet (order like in DB Sheet)
    c) And sort the DB and TD sheet by column wise

    Thanks & Regards.

    Anand R
    Attached Files Attached Files

  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: Compare Sheets and sort columns based on sheet 3

    See if this is what you wanted:

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    12-21-2014
    Location
    chennai
    MS-Off Ver
    2010
    Posts
    37

    Re: Compare Sheets and sort columns based on sheet 3

    Hi,

    There would be only one file (input file) and i need the out put as mentioned in out put file after running the macro. For reference i have sent 2 excel documents. Please don't write any values like TRUE or FALSE in any sheets. In my input file please compare the TD and DB sheet and do the following...

    a) Check the order of columns are placed (present) in DB Sheet
    b) Check if the order of columns are placed differently in TD sheet, then place as in DB sheet (order like in DB Sheet)
    c) And sort the DB and TD sheet by column wise

    Thanks
    Anand R

  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: Compare Sheets and sort columns based on sheet 3

    Another attempt:

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    12-21-2014
    Location
    chennai
    MS-Off Ver
    2010
    Posts
    37

    Re: Compare Sheets and sort columns based on sheet 3

    Hi,

    Why are you using

    Set wo = Workbooks("Output_Sheet.xlsx")

    As i said earlier, my sample file will be like input file that i attached. I need to do the following

    a) Check the order of columns are placed (present) in DB Sheet
    b) Check if the order of columns are placed differently in TD sheet, then place as in DB sheet (order like in DB Sheet)
    c) And sort the DB and TD sheet by column wise.

    after running the macro, the file should be like output file...So doesn't mean that we need to take output file.

    In our case, all excel files are stored in a path and need to iterate each excels (input file) need out put as in output file after running your code.

    Hope i didn't confuse you.

    Thanks
    Anand R

    After above operation i need to save it

    Thanks
    Anand r

  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: Compare Sheets and sort columns based on sheet 3

    Hi Anand,

    I am confused - I used Input_Sheet and Output_Sheet because that's what you provided in your sample. What is it that you need that I haven't supplied?

    a) Check the order of columns are placed (present) in DB Sheet
    b) Check if the order of columns are placed differently in TD sheet, then place as in DB sheet (order like in DB Sheet)
    c) And sort the DB and TD sheet by column wise.
    I believe that my routine does all that?

  13. #13
    Registered User
    Join Date
    12-21-2014
    Location
    chennai
    MS-Off Ver
    2010
    Posts
    37

    Re: Compare Sheets and sort columns based on sheet 3

    Hi,

    Let me put straight forward...

    i want the output as in output file from input file... ie.. we have only one input file. In that input i need to do the following things

    a) Check the order of columns are placed (present) in DB Sheet
    b) Check if the order of columns are placed differently in TD sheet, then place as in DB sheet (order like in DB Sheet)
    c) And sort the DB and TD sheet by column wise.
    d) i need the output as in output file after doing the above a,b,c steps
    e) Save the input file


    I saw your code.. you are using the output file .. not at all. my output should be like in output file by overwriting the values in existing input file itself.

    Hope i am correct now this time

    Thanks
    Anand R

  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: Compare Sheets and sort columns based on sheet 3

    Maybe:

    Please Login or Register  to view this content.

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

    Re: Compare Sheets and sort columns based on sheet 3

    Quote Originally Posted by anandrajagopal View Post
    I Need to compare TD sheet with DB2 and make sure we have the same order of columns present in TD Sheet, if not then need to sort it according to DB2 sheet.
    Try
    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    12-21-2014
    Location
    chennai
    MS-Off Ver
    2010
    Posts
    37

    Re: Compare Sheets and sort columns based on sheet 3

    Hi,

    Let me try and i'll let you know..

    BTW, Is it possible for row wise

    a) Check the order of columns are placed (present) in DB Sheet
    b) Check if the order of columns are placed differently in TD sheet, then place as in DB sheet (order like in DB Sheet)
    c) And sort the DB and TD sheet by row wise.
    d) i need the output as in output file after doing the above a,b,c steps
    e) Save the input file


    regards,

    Anand R

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

    Re: Compare Sheets and sort columns based on sheet 3

    What is your goal?

    If you want to check the difference, no need to sort at all.

+ 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. Replies: 0
    Last Post: 11-25-2014, 05:30 PM
  2. Compare two sheets,copy and paste unique rows based on values in 2 columns
    By ooggiemobile in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-02-2013, 03:58 AM
  3. Sort multiple sheets based on 2 columns in 1 sheet
    By grahamc in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-29-2012, 04:39 PM
  4. Compare multi Columns in Different Sheets and Post it result on a 3rd sheet
    By steven.demei in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-19-2011, 07:18 AM
  5. Compare Two Columns in Separate Sheets and copy fields over to third sheet
    By initiator in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-29-2010, 09:23 AM

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