+ Reply to Thread
Results 1 to 27 of 27

extract excel sheet and save in reference folder

  1. #1
    Forum Contributor
    Join Date
    04-19-2015
    Location
    pakistan
    MS-Off Ver
    2013
    Posts
    335

    extract excel sheet and save in reference folder

    hello all

    PFA ..in given sheet in column "J" file names are under it.i have similar file name folder at desktop and sub folder in it with company name which is in sheet 3 column B & C..
    all folder and sub folders are in one folder which name "Main" at desktop.

    i want in sheet 1 only UM 01 data automatically save in sub folder of UM 01 and similar all others.

    result like sheet 2..mean only excel sheet in sub folder




    Gondal
    Attached Files Attached Files
    Last edited by gondal; 05-15-2016 at 05:26 AM.

  2. #2
    Forum Contributor
    Join Date
    04-19-2015
    Location
    pakistan
    MS-Off Ver
    2013
    Posts
    335

    Re: Auto extract data and save in reference folder

    pl anyone can help guru's..??

  3. #3
    Forum Contributor
    Join Date
    04-19-2015
    Location
    pakistan
    MS-Off Ver
    2013
    Posts
    335

    Re: Auto extract data and save in reference folder

    hllo.not yet any response..?

  4. #4
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: extract excel sheet and save in reference folder

    Can you perhaps clarify the following:

    - Are there already folders named after each company in Sheet3 column C?
    - Am I understanding correctly that each of those folders contains a workbook called 'UM 01' or whatever the associated UM is?
    - Do those workbooks already contain data exactly like you've shown in Sheet2?
    - What is the file path of one of those workbooks?

    This sort of procedure isn't one that anyone other than you can properly test, so it'll be easier to find assistance if you can be precise about where the data is ultimately going.

  5. #5
    Forum Contributor
    Join Date
    04-19-2015
    Location
    pakistan
    MS-Off Ver
    2013
    Posts
    335

    Re: extract excel sheet and save in reference folder

    hi contosh..happy to see u after long time...
    yes there is already folder at desktop with the name of Main...for example...c:\desktop\Main\UM 01\AEG TRAVEL SERVICES (PVT) LTD , c:\desktop\Main\UM 02\ASAD PACKAGES

    no folder has data or any excel sheet..Main folder has all UM 01 to UM 86 folders, and each sub folder has another folder with company name..which i mentioned in sheet 3..

    Gondal

  6. #6
    Forum Contributor
    Join Date
    04-19-2015
    Location
    pakistan
    MS-Off Ver
    2013
    Posts
    335

    Re: extract excel sheet and save in reference folder

    moreover i made these folders with below VBA..may this will clear your picture more..

    Sub Create_Folders_Desktop()
    'create main folder in desktop
    CreateObject("Scripting.FileSystemObject").CreateFolder (CreateObject("WScript.Shell").specialfolders(4) & "\Main")
    'get path for new folder
    MainFolderPath = CreateObject("WScript.Shell").specialfolders(4) & "\Main" & "\"
    'put range with new foldernames in array
    sn = Sheets("Sheet1").Cells(1).CurrentRegion.Value
    'check and replace invalid characters
    For i = 2 To UBound(sn)
    For Each v In Array("/", "\", "|", ":", "*", "?", "<", ">", """")
    sn(i, 3) = Replace(sn(i, 3), v, "_")
    Next
    Next
    'create new folders and subfolders
    For i = 2 To UBound(sn)
    MkDir MainFolderPath & sn(i, 2)
    MkDir MainFolderPath & sn(i, 2) & "\" & sn(i, 3)
    Next
    'write array back to sheet to check replacement of invalid characters in new foldernames
    Sheets("Sheet1").Cells(1).Resize(UBound(sn), UBound(sn, 2)) = sn
    End Sub

  7. #7
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: extract excel sheet and save in reference folder

    Give the procedure below a try. It works for me on a shortened sample size. Be sure that the "MyPath" line of the code matches your file path as far as the "Main" folder. Let me know how it goes...

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    04-19-2015
    Location
    pakistan
    MS-Off Ver
    2013
    Posts
    335

    Re: extract excel sheet and save in reference folder

    hi cantosh
    when i run this VBA on sheet 1,this is only desperate the UM 01 and more over also remove the remaining data of original sheet only shows UM 01.


    Gondal

  9. #9
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,500

    Re: extract excel sheet and save in reference folder

    Make sure folders are created with names on Sheet3. (Run top macro to achieve this)
    Then run second macro to create seperate files in each folder.
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    04-19-2015
    Location
    pakistan
    MS-Off Ver
    2013
    Posts
    335

    Re: extract excel sheet and save in reference folder

    hi bakerman..
    its works till UM 41.. after shows error and did not run again..

    Gondal

  11. #11
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,500

    Re: extract excel sheet and save in reference folder

    That's why I told you to create folder structure according to sheet3 first.
    The problem lies in PROFESSIONALS' ACADEMY OF COMMERRCE. After running first folder-create macro name is changed into PROFESSIONALS_ ACADEMY OF COMMERRCE and then it works fine.

  12. #12
    Forum Contributor
    Join Date
    04-19-2015
    Location
    pakistan
    MS-Off Ver
    2013
    Posts
    335

    Re: extract excel sheet and save in reference folder

    is this possible that i will change the name of sub folder instead of company with 01,02,03 than run macros for copy data after change the excel sheet name with company name from 01,02,03...to avoid such problem again again...

  13. #13
    Forum Contributor
    Join Date
    04-19-2015
    Location
    pakistan
    MS-Off Ver
    2013
    Posts
    335

    Re: extract excel sheet and save in reference folder

    or cross the miss match and copy all other and shows miss sheet at end and also miss the folder if already sheet exist....

  14. #14
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: extract excel sheet and save in reference folder

    As Bakerman mentioned, the trick is that your folder structure must exactly match what you have in Sheet3. His 'Create_Folders_Desktop' procedure is a smart addition. The macro I posted works for me, but I created all of the folders from scratch based on Sheet3, whereas you have something already in place. Make sure all of the folder names line up perfectly with Sheet3 and you should get accurate results.

  15. #15
    Forum Contributor
    Join Date
    04-19-2015
    Location
    pakistan
    MS-Off Ver
    2013
    Posts
    335

    Re: extract excel sheet and save in reference folder

    ok well cantosh/bakerman..i have changed, i have create different folder with company name to numeric like: c:\desktop\Main\UM 01\1.....can u make necessary changes in VBA to copy data and avoid duplicate sheet if already exist.if possible ..??

  16. #16
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,500

    Re: extract excel sheet and save in reference folder

    You can't keep changing your mind.
    I've made you a new example file in which company names are all set to wright format on Sheet3.
    When in the future you want to add a new customer I also added a small Userform which shows when you activate sheet3. Just fill in customernumber and customercompany.
    The name is automatically checked on unautherized characters and adapted to proper format, a new UM number is assigned and a new folder is created.
    I changed format of UM numbers to 000 so you can add up to 999 customers.
    So all you have to do is create Foldertree with first code and then run second code to create files in each folder and 20 sec later you're done.
    Attached Files Attached Files

  17. #17
    Forum Contributor
    Join Date
    04-19-2015
    Location
    pakistan
    MS-Off Ver
    2013
    Posts
    335

    Re: extract excel sheet and save in reference folder

    thnx bakerman..your help is very much valuable for me..bundle of thnx

  18. #18
    Forum Contributor
    Join Date
    04-19-2015
    Location
    pakistan
    MS-Off Ver
    2013
    Posts
    335

    Re: extract excel sheet and save in reference folder

    Dear bakerman
    i am facing one problem in sheet when i go in sheet 3 and enter info its create 2 same number cust and company.. pl guide if i update sheet 3 after that i will run macros again of create sheet..or it will pick automatically....thnx

  19. #19
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,500

    Re: extract excel sheet and save in reference folder

    Added 2 checks on userform. First number is checked for duplicates afterwards companyname. When all is allright then name is added to list and UM-folder and company subfolder are created and userform disappears automatically. When nuber or name are duplicate userform stays active so you know something is wrong.
    Attached Files Attached Files

  20. #20
    Forum Contributor
    Join Date
    04-19-2015
    Location
    pakistan
    MS-Off Ver
    2013
    Posts
    335

    Re: extract excel sheet and save in reference folder

    thnx for helping out me, when i update sheet 3, its create new folder and update sheet 3 as my per my info provided and also create folder in path but when i update sheet 1 its not create sheet in ref folder, if i run macros again it asked for replace for sheet, if i make yes file replaced then its asked again for 2nd sheet and continue asked and if say no its showing error and held sheet..pl guide further regarding this

    Gondal

  21. #21
    Forum Contributor
    Join Date
    04-19-2015
    Location
    pakistan
    MS-Off Ver
    2013
    Posts
    335

    Re: extract excel sheet and save in reference folder

    bakerman.??

  22. #22
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,500

    Re: extract excel sheet and save in reference folder

    Your initial question has already been solved so what is it you want to achieve now ?
    If you want to create new file and replace old one every time you add a row on sheet1 I'd create a Userform to do so since you then have more control on how names are inserted so less chance on error by wrong name etc... Up until now however I've not seen too much input from your end so I expect some more from now one. This forum is here to assist on whatever project, not to create a working application for you. For that there are commercial services available.

  23. #23
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,500

    Re: extract excel sheet and save in reference folder

    Okay, added second Userform to fiil in your data on sheet1.
    When you select company from combobox then cust-number, UM-number and company-address are automatically filled.
    Finish all fields and click button. All data is added in bottom-row and new file is created in folder/subfolder from company, containing latest changes.
    Attached Files Attached Files

  24. #24
    Forum Contributor
    Join Date
    04-19-2015
    Location
    pakistan
    MS-Off Ver
    2013
    Posts
    335

    Re: extract excel sheet and save in reference folder

    sorry for disturbing bakerman..on sheet 1 no uniform is showing and when i entered data in sheet 3 in uniform ,no UM number is created and folder/sun folder and also no company address filled


    Gondal

  25. #25
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,500

    Re: extract excel sheet and save in reference folder

    Updated version.
    Attached Files Attached Files

  26. #26
    Forum Contributor
    Join Date
    04-19-2015
    Location
    pakistan
    MS-Off Ver
    2013
    Posts
    335

    Re: extract excel sheet and save in reference folder

    thnx bakerman such a kind help

  27. #27
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,500

    Re: extract excel sheet and save in reference folder

    Good luck and thanks for the rep.

+ 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. Auto save to specific folder based on cell contents
    By JamesT1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-10-2015, 09:07 AM
  2. macro to bring up stored workbook, auto save to a new folder, then auto fill
    By Rick23 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-29-2014, 06:58 PM
  3. vba to print active sheet to pdf, auto save in specific folder then mail using outlook
    By lathamashly in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-21-2014, 04:57 AM
  4. auto save e-mail attachment to folder after sending
    By ncaravela in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-16-2010, 05:23 PM
  5. auto save to a folder resurrection
    By stevesunfold in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-22-2008, 08:08 AM
  6. Save WB from reference found in cell D1 to specific folder
    By Annette in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-13-2006, 12:35 PM
  7. I like to open a folder,auto print,save then close
    By tied of opening files in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-22-2005, 06:06 PM

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