+ Reply to Thread
Results 1 to 19 of 19

Copy contents from "Child" file to a "Master"

  1. #1
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Copy contents from "Child" file to a "Master"

    Dear All,

    I hope you are all well.

    I want to ask your advise, if possible, on a code I have.

    Basically, the code copy contents from 4 "Child" files to a "Mater" file.

    Everything works smoothly but no data is being copied from the "Child" files.

    Is there something wrong on the code:

    Please Login or Register  to view this content.
    The other thing I've noticed is that if a "Child" file is open, I cannot run the code. Is there a way that even a "Child" file is open, the code can copy it's contents on the background?

    Your assistance on this matter will be highly appreciated.

    Best regards,
    Filipe
    Last edited by pipoliveira; 02-12-2014 at 09:11 AM.

  2. #2
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Copy contents from "Child" file to a "Master"

    It look that you have problem in these rows:

    Please Login or Register  to view this content.
    and all of that type after this one

    you try to put the value of some 501 cells in a single cell

    it should be

    Please Login or Register  to view this content.
    Note that you copy different number of rows 500 or 501.

    The second problem - you will get an error if the file is already open, so you should check if file is open before trying to open it
    Last edited by buran; 02-12-2014 at 09:26 AM.
    If you are pleased with a member's answer then use the Star icon to rate it.

  3. #3
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Re: Copy contents from "Child" file to a "Master"

    Hi buran,

    Thank you for your prompt reply.

    I've changed the code as you've mentioned above but I still cannot have any data copied to the "Master" file and there's no errors on the code either. There must be something that is not right.

    As for the second problem, is there a way to copy the contents of a "Child" file even it's open?

    Many thanks in advance and kind regards,
    Filipe

  4. #4
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Copy contents from "Child" file to a "Master"

    Hm, it's hard without the files, but one more thing - note that you copy data from Monitoring to Master Nomination. Is that right?
    Regarding the second problem - my understanding is that you got error when you try to run the code and it try to open already open file. Is that correct?

  5. #5
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Re: Copy contents from "Child" file to a "Master"

    Hi buran,

    There is a Master file with extension "Master Dashboard" and the Child files. The master and child files have the same worksheet names ("Customer Nomination"; "Customer Monitoring" & "Improvement Suggestions").

    The only thing that is not the same between Master and Child files is the contents because the Master file only have the required information and not all of it.

    Regarding the second problem:

    The "Child" files will be stored on a shared drive that can be accessed by employees from different locations, so we can not tell who's using the file. If there was a peace of code that could say to copy contents even the file is open, that could be great.

    Please let me know if you need further information.

    Best regards,
    Filipe.

  6. #6
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Copy contents from "Child" file to a "Master"

    Please Login or Register  to view this content.
    You check for the last row in wsMasterMon and then you copy data to wsMasterNom

    I think that's not right.

    Regarding the second question - my impression was that the file is already open on the same pc. if it's on a shared drive and some one has already open the file, it should open in read only mode. if it doesn't try to add ReadOnly:=True to the Opne method. Also maybe there is some policy in place that prevents the file from opening if its already open?

  7. #7
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Copy contents from "Child" file to a "Master"

    Please Login or Register  to view this content.
    You check for the last row in wsMasterMon and then you copy data to wsMasterNom

    I think that's not right.

    Regarding the second question - my impression was that the file is already open on the same pc. if it's on a shared drive and some one has already open the file, it should open in read only mode. if it doesn't try to add ReadOnly:=True to the Opne method. Also maybe there is some policy in place that prevents the file from opening if its already open?

  8. #8
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Copy contents from "Child" file to a "Master"

    sorry for duplicate post, there was some problem while posting

  9. #9
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Re: Copy contents from "Child" file to a "Master"

    Let me try to explain.

    As the Master file will have the contents of all 4 Child files, I assumed that I need to say in VBA to compile all Child information in the Master one by one or else it might replace values instead of maintaining all Child files information, one after the other.

    I did something similar that worked real fine, but that one was only a Master and 1 Child. It copies the contents from one to the other. The difference is that the code copies all table from Child to Master.

    Here's the code I used for that file and works perfectly:
    Please Login or Register  to view this content.
    On this new file I am creating, I need to have all childs info from each sheet to the Master. The problem might be that the "Child" table on each sheet contains about 25 columns and on the Master, I only need about 5 or 9 depending on the sheet and the headers are not in the same order as the "Child" files.

    Please let me know if you need further information.

    I can try to make a Demo file if you think that will help.

    Many thanks in advance for checking this up.

    Best regards,
    Filipe
    Last edited by pipoliveira; 02-12-2014 at 10:45 AM.

  10. #10
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Re: Copy contents from "Child" file to a "Master"

    Sorry buran,

    You are right,

    On that line I should have:
    Please Login or Register  to view this content.
    But still it does not copy anything.

    Any ideas will be highly appreciated.

    Best regards,
    Filipe

  11. #11
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Copy contents from "Child" file to a "Master"

    I'm looking at your code and I noticed something else

    Look at this code

    Please Login or Register  to view this content.
    iRowNom is the last row in wsMasterNom. after that you copy values to wsMasterNom.Cells(iRowMon, 10). I don't see where in the code up to that point variable iRowMon has been initialized. That code should rise an error, so it's not possible that *Everything works smoothly but no data is being copied from the "Child" files.*

  12. #12
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Re: Copy contents from "Child" file to a "Master"

    That was already changed, now it's:
    Please Login or Register  to view this content.
    Honestly, when the code was as I posted, I did not received any errors and the code ran till the end as all "Child" files closed and I did received the MsgBox text set at the end of it.

    I might try the ".Copy" instead of ".Value" for the child range and ".PasteSpecial" for the "Master" to see what happens.

    Best regards,
    Filipe

  13. #13
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Copy contents from "Child" file to a "Master"

    well. I give up

  14. #14
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Re: Copy contents from "Child" file to a "Master"

    No worries,

    Thanks a million for trying.

    Best regards,
    Filipe.

  15. #15
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Copy contents from "Child" file to a "Master"

    One more thing:

    Please Login or Register  to view this content.
    It looks like that you overwrite data from J12:J511 with data from L12:L511 both are copied to column 10, starting iRowSug

  16. #16
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Re: Copy contents from "Child" file to a "Master"

    Thanks buran,

    I did noticed that error previously and I have changed it

    Thanks a million.

  17. #17
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Re: Copy contents from "Child" file to a "Master"

    Hi buran,

    I thought you might be interested to know.

    I have solved the problem.

    Apparently, I copied/paste the following statement to each different "Child" file:
    Please Login or Register  to view this content.
    I don't know why but it worked. Now it updates all "Child" files to the "Master".

    Now I have a doubt. This code was created on a module to test it but I would like to have it on the "Workbook_Open" event.

    The thing I need is to avoid duplication. Let's say that I need a code that focus on Column "J" for duplication.

    "J" stands for "Customer Number" header and there shouldn't be more than 1 data for each customer.

    What will be the best peace of code to use?

    Your assistance on this matter will be highly appreciated.

    Best regards,
    Filipe

  18. #18
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Copy contents from "Child" file to a "Master"

    sorry, not able to help with this

  19. #19
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Re: Copy contents from "Child" file to a "Master"

    No worries,

    Thanks a million.

    The problem of this thread was finished so I will maintain this as Solved.

    Thanks a million,
    Filipe

+ 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: 4
    Last Post: 11-17-2013, 12:05 PM
  2. [SOLVED] How to USE """"" cells count """"" change font color
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 06:14 AM
  3. Replies: 1
    Last Post: 06-06-2013, 06:28 PM
  4. MSoffice Outlook 2003 message to be saved in C dir with the file name "From" "Sent" "Sub"
    By shailendra0509 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-09-2012, 01:32 AM
  5. How can i copy value from "HTMLText"(EMBED("Forms.HTML:Text","")),using Macro
    By andrewyang in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2010, 12:47 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