+ Reply to Thread
Results 1 to 25 of 25

Import 2 different sheets after formatting then replace data

  1. #1
    Registered User
    Join Date
    11-29-2017
    Location
    Clearwater, FL
    MS-Off Ver
    2016
    Posts
    47

    Import 2 different sheets after formatting then replace data

    In my workbook "Floor Captain Role" on sheet "Controls" I have a button that I have that says Update IF Arrivals. When I press this button I would like for it to open a workbook called "ContainerArrivalReport" located on my server at (F:\Call Center\Harrison\Rays\IF-Arrivals) then I need it to do these steps:
    Delete Column "E"
    Delete Column "E" again
    Delete Column "F"
    Unhide columns "F-K"
    Delete row #1 & #2
    Cut column "E" and insert the cut cells to column "G"
    Cut column "B" and insert the cut cells to column "G"

    After that is completed then remove any rows that have a blank in the first column then copy all of that information to the sheet in workbook Floor captain role onto sheet "IFContainers" starting at A7. After that is copied I need it to open workbook "ContainerETAReport" located at (F:\Call Center\Harrison\Rays\IF-Arrivals) and copy everything from A3 down to the bottom (which will change daily depending on how many we have) and insert that copied info to the "IFContainers" sheet in the workbook Floor Captain Role under the last line of the previous information.

    After all the data is collected I need to find and replace the following:
    CMP - COMPLETED
    AVL - AVAILABLE
    PLN - PLANNED
    DSP - TRANSIT
    STD - TRANSIT

    After all of that have the macro close all open books except the one called Floor Captain Role. Then save the sheet "IFContainers" as "IFContainerArrival" at the following location (F:\Policies Procedures and Forms\Call Center)

    I have attached all my documents so you will be able to see everything I am working with. I greatly appropriate any help with this!!! If there are any questions please do not hesitate to contact me directly!!!
    Attached Files Attached Files

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Import 2 different sheets after formatting then replace data

    this is untested, so I strongly suggest that you make copies of your files and test it before applying it to your original files.
    Please Login or Register  to view this content.

  3. #3
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Import 2 different sheets after formatting then replace data

    I'm willing to give this a try (no promises) but I have a few questions. In your "ContainerArrivalReport" you have merged cells in columns D and E so this makes it a little confusing when it comes to deleting the columns. Can you list the columns that you want to delete by using the column headers or do you just want to delete all columns in "ContainerArrivalReport" so that those columns remaining match the columns in "IFContainers"? By the way, merged cells should be avoided at all costs because they cause havoc for macros. Currently, there is only one column which is hidden but you say that you want 3 columns unhidden. Do you simply want all columns to be visible? When columns B and E are cut to column G, do you want the data in column B to be placed directly below the data from column E?
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  4. #4
    Registered User
    Join Date
    11-29-2017
    Location
    Clearwater, FL
    MS-Off Ver
    2016
    Posts
    47

    Re: Import 2 different sheets after formatting then replace data

    So basically I need the columns to line up out of the "ContainerArrivalReport" to line up with the columns in "IFContainers" sheet. Deleting column E will not affect the data from the 1st step, then when you cut & insert the cut cells it moves the data to the left, so when you cut column B and insert into column G - it moves to the left & the data that was in column B will now be in G.

  5. #5
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Import 2 different sheets after formatting then replace data

    Would it work for you if we simply copied the data in "ContainerArrivalReport" to the matching columns in "IFContainers" without deleting or cutting any columns in "ContainerArrivalReport".

  6. #6
    Registered User
    Join Date
    11-29-2017
    Location
    Clearwater, FL
    MS-Off Ver
    2016
    Posts
    47

    Re: Import 2 different sheets after formatting then replace data

    Yeah, that works for me as long as it gets put in the correct order! I also need it to keep the current format as well, the code that was submitted above changes the font to yellow. I need it to stay black.
    Last edited by jamesraywebber; 01-12-2018 at 12:20 PM. Reason: Details

  7. #7
    Registered User
    Join Date
    11-29-2017
    Location
    Clearwater, FL
    MS-Off Ver
    2016
    Posts
    47

    Re: Import 2 different sheets after formatting then replace data

    Also once we save the sheet for the last process, is there a way it can have a password automatically put onto that file?

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Import 2 different sheets after formatting then replace data

    Do you want to prevent the file from being opened unless the correct password is entered? I have to go out for a few hours so I'll start on a solution as soon as I get back.

  9. #9
    Registered User
    Join Date
    11-29-2017
    Location
    Clearwater, FL
    MS-Off Ver
    2016
    Posts
    47

    Re: Import 2 different sheets after formatting then replace data

    correct so when the file that is saved is opened, it will require the password! Thank you for all your help!

  10. #10
    Registered User
    Join Date
    11-29-2017
    Location
    Clearwater, FL
    MS-Off Ver
    2016
    Posts
    47

    Re: Import 2 different sheets after formatting then replace data

    So my end result should look like this file. Also its not a password to open the file, but a password to allow modifications.
    Attached Files Attached Files

  11. #11
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Import 2 different sheets after formatting then replace data

    Give this a try. I haven't added the password part yet. Let me know how this works and we'll go from there.
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    11-29-2017
    Location
    Clearwater, FL
    MS-Off Ver
    2016
    Posts
    47

    Re: Import 2 different sheets after formatting then replace data

    Works pefectly, except I keep getting an error at:
    Please Login or Register  to view this content.
    Any ideas? Thank you so much by the way!

    Also the file that is saved is not exactly what is copied. It looks like Cell C2, and row 4 is different colors. Is there a special paste were it copies exactly as it appears?
    Last edited by jamesraywebber; 01-12-2018 at 06:55 PM. Reason: Missing details

  13. #13
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Import 2 different sheets after formatting then replace data

    You can probably fix that by changing this
    Please Login or Register  to view this content.
    to this
    Please Login or Register  to view this content.

  14. #14
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Import 2 different sheets after formatting then replace data

    @JLGWhiz: Thank you for your suggestion. I believe that the OP wants to save the sheet "IFContainers" in a file without the "Control" sheet. I think that your suggestion saves the entire workbook with the new name which includes the "Control" sheet. I have made a few changes to take care of the error and to delete Sheet1 to 3.
    Please Login or Register  to view this content.

  15. #15
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Import 2 different sheets after formatting then replace data

    I think that your suggestion saves the entire workbook with the new name which includes the "Control" sheet.
    If the declarations and set statement in the code are correct, it should only create a new workbook with only the IFContainers worksheet in it. Much easier than building in increments. But it was only a suggestion.

  16. #16
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Import 2 different sheets after formatting then replace data

    @JLGWhiz: You are perfectly correct. My apologies and thank you for the suggestion.

  17. #17
    Registered User
    Join Date
    11-29-2017
    Location
    Clearwater, FL
    MS-Off Ver
    2016
    Posts
    47

    Re: Import 2 different sheets after formatting then replace data

    Were you able to figure out how to put the password on the sheet? Or maybe we can have the IFArrivals sheet open from that location, copy everything over & then save & close?

  18. #18
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Import 2 different sheets after formatting then replace data

    In a previous post you said:
    its not a password to open the file, but a password to allow modifications
    .
    Could you please describe in a little more detail exactly what you want to do, what modifications, which cells, etc.

  19. #19
    Registered User
    Join Date
    11-29-2017
    Location
    Clearwater, FL
    MS-Off Ver
    2016
    Posts
    47

    Re: Import 2 different sheets after formatting then replace data

    So after the file saves for the IFContainerArrivals, it needs to have a password so it can not be modified once it is closed.

  20. #20
    Registered User
    Join Date
    11-29-2017
    Location
    Clearwater, FL
    MS-Off Ver
    2016
    Posts
    47

    Re: Import 2 different sheets after formatting then replace data

    This is the current code that I have you helped me with:
    Please Login or Register  to view this content.
    So after the workbook is copied, I need the workbook to have a password to modify it.

  21. #21
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Import 2 different sheets after formatting then replace data

    Here is the revised macro. The "IFContainerArrivals" sheet is protected and locked with the password "mypassword". If you want to change the password, unlock the sheet using "mypassword", lock it again with your new password and change the password in the code to match the new one. The user will not be able to modify the sheet unless it is unlocked with a valid password.
    Please Login or Register  to view this content.

  22. #22
    Registered User
    Join Date
    11-29-2017
    Location
    Clearwater, FL
    MS-Off Ver
    2016
    Posts
    47

    Re: Import 2 different sheets after formatting then replace data

    Perfect - thank you so much for your help!

  23. #23
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Import 2 different sheets after formatting then replace data

    You are very welcome.

  24. #24
    Registered User
    Join Date
    11-29-2017
    Location
    Clearwater, FL
    MS-Off Ver
    2016
    Posts
    47

    Re: Import 2 different sheets after formatting then replace data

    So after working with this code for a while, I realized there is bit of an issue. Our associates are not able to search by container # while the sheet is locked. Is there a way we can make it keep the filters from row 6 or instead of password protected, put a password to not modify?

  25. #25
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Import 2 different sheets after formatting then replace data

    I am assuming that you want to be able to filter the data when the sheet is protected. If that is correct, unprotect the sheet and turn on the Filter so that the little down arrows for filtering are visible. When you protect the sheet again, select "Use Autofilter" in the drop down, enter the password and click "OK". Now you can filter the data even though the sheet is protected. Also, in the macro, replace this line of code:
    Please Login or Register  to view this content.
    with this line:
    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)

Similar Threads

  1. data import from several sheets
    By MrJim005 in forum Excel General
    Replies: 1
    Last Post: 08-20-2015, 10:35 PM
  2. VBA to Import data or sheets from other workbook
    By caabdul in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-23-2014, 04:32 AM
  3. Import data from changing sheets
    By itsunclebill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-22-2011, 05:21 PM
  4. Import data into word document to replace single words
    By Michael Klund in forum Excel General
    Replies: 1
    Last Post: 12-10-2010, 11:37 AM
  5. Data Import - formatting
    By sjs in forum Excel General
    Replies: 2
    Last Post: 05-10-2006, 12:50 PM
  6. how do import data from two sheets into one
    By vbidiot in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-23-2006, 08:20 PM
  7. Macro based Import Data Inserts Cells, I want Replace
    By bramweisman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-09-2005, 01:05 AM

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