+ Reply to Thread
Results 1 to 10 of 10

Macro to combine the sheets only if the number of rows are two.

  1. #1
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Dubai
    MS-Off Ver
    Excel For Mac V16 365
    Posts
    145

    Macro to combine the sheets only if the number of rows are two.

    Hiii,

    thanks for helping.

    I have a macro that combines all the sheets in the workbook.

    i need to alter this macro so that only those sheets with two rows in total gets combined and those with more than two rows remain separate.

    Please Login or Register  to view this content.
    Any ideas??

    Many thanks

    Gokz

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro to combine the sheets only if the number of rows are two.

    Gokz,
    When you say two rows, does this include the heading? The code will look for a last row in a sheet including a heading, i.e it will count the heading as a data as well.
    Let's say you have 3 sheets. 1 sheet has 3 rows of data, the first row being the header, the last row in this case is 3, so the code will ignore this sheet as it has over 2 rows. I think there are few unknowns on your data, so would be easier if you could attach a sample of your book.

  3. #3
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Dubai
    MS-Off Ver
    Excel For Mac V16 365
    Posts
    145

    Re: Macro to combine the sheets only if the number of rows are two.

    Hiiiii AB33,

    sorry...i missed the heading...so it should be 3.....

    i have large amount of data that is very difficult to replace with dummy data.

    can i amend the above macro??

    thanks

    Gokz

  4. #4
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Dubai
    MS-Off Ver
    Excel For Mac V16 365
    Posts
    145

    Re: Macro to combine the sheets only if the number of rows are two.

    i have around 150 sheets with 3 rows of data and 5 rows data. i need to combine only those with 3 rows of data.

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro to combine the sheets only if the number of rows are two.

    Gok,
    I have came up with different code and changed some of the names. It is partly guess work, as I could not see the format of your data.
    A number of assumptions on my code.
    The code clears any data and repopulate the Murex with the new data.
    The header on Murex is copied from one of the sheets .
    The headers from each sheet are not copied, ie the code only copies from row 2, but the header will be counted towards deciding if a sheet has 3 rows. Have a go and see

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Dubai
    MS-Off Ver
    Excel For Mac V16 365
    Posts
    145

    Re: Macro to combine the sheets only if the number of rows are two.

    hiiii,

    Thanks, but it dint work..the sheet was blank.

    i am attaching an excel dummy sheet where i tried.

    Please let me know.

    Thanks

    Gokz
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Dubai
    MS-Off Ver
    Excel For Mac V16 365
    Posts
    145

    Re: Macro to combine the sheets only if the number of rows are two.

    Any ideas friends??

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro to combine the sheets only if the number of rows are two.

    Will back soon
    Last edited by AB33; 01-18-2013 at 06:02 AM.

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro to combine the sheets only if the number of rows are two.

    Change this line and now works

    Please Login or Register  to view this content.
    IN TO

    Please Login or Register  to view this content.
    Last edited by AB33; 01-18-2013 at 05:59 AM.

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro to combine the sheets only if the number of rows are two.

    Gokzee,
    The code works as it was, so I do not know what the issue is. I did not get the time to check it this morniing. I now have checked it again and you do not need to split up the copy in to two rows. If you have any issue, let me know and will attach the code with your data

    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)

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