Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: Macro for Opening files and copy the contents of the File

  1. #11
    Junior Member
    Join Date
    Aug 2012
    Posts
    12
    Rep Power
    0
    Hi,

    Thanks for quick reply.I have tried that too, but macro runs fine and opens all the file but result is zero. I don't know where all the data s are copied.
    Please find the file which i tried once again and let me know do i need to change anything in this code.

    Thanks & Regards,
    Ravi.C
    Attached Files Attached Files

  2. #12
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi

    Attach one source file as well.
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  3. #13
    Member
    Join Date
    Jul 2012
    Posts
    55
    Rep Power
    13
    Quote Originally Posted by ravichandavar View Post
    Hi,

    Thanks for quick reply.I have tried that too, but macro runs fine and opens all the file but result is zero. I don't know where all the data s are copied.
    Please find the file which i tried once again and let me know do i need to change anything in this code.

    Thanks & Regards,
    Ravi.C

    Hi,

    For me it works.
    All files you want to copy must have the same header and be placed in the same place. I used your file, without modification.

  4. #14
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    It should work even if the headers are in different place.
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  5. #15
    Member
    Join Date
    Jul 2012
    Posts
    55
    Rep Power
    13
    Quote Originally Posted by Admin View Post
    It should work even if the headers are in different place.

    Yes, headers can be in any position but in the same range, say A1: L1, if headers are (even if they are the same in all pages) say D5: P5 code does not work. If file 1, 2...10 has header in range A1:L1 and in file 11 the header is in D5:P2, cod don't work.

  6. #16
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Adjusting this line would do the trick.

    Code:
    d = .Range("a1").CurrentRegion.Value2
    rather than taking the current region you can explicitly put the range.
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  7. #17
    Member
    Join Date
    Jul 2012
    Posts
    55
    Rep Power
    13
    Quote Originally Posted by Admin View Post
    Adjusting this line would do the trick.

    Code:
    d = .Range("a1").CurrentRegion.Value2
    rather than taking the current region you can explicitly put the range.

    Yes you are right.

    I am referring to the following situation:
    if in file 1 to 5 are header in the range A1: F1 and data in A2: F25, and the file 6 the header is in the range I5: N5 and data in I6: N30 when run the code, error appears in line For i = LBound (DataHeader) To UBound (DataHeader)

Similar Threads

  1. Replies: 5
    Last Post: 01-12-2013, 02:49 AM
  2. Macro to copy data from a set of excel files
    By Sreejesh Menon in forum Excel Help
    Replies: 5
    Last Post: 11-15-2012, 11:17 AM
  3. Macro to create files as per the contents in a column
    By Praveen Bj in forum Excel Help
    Replies: 1
    Last Post: 07-05-2012, 09:07 PM
  4. Replies: 1
    Last Post: 06-26-2012, 08:17 PM
  5. Opening a Pdf file using VBA
    By littleiitin in forum Excel Help
    Replies: 2
    Last Post: 11-30-2011, 03:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •