+ Reply to Thread
Results 1 to 20 of 20

help Creating seperate files from existing sheets

  1. #1
    Registered User
    Join Date
    02-12-2020
    Location
    Swe
    MS-Off Ver
    2016
    Posts
    15

    help Creating seperate files from existing sheets

    Hi
    I am having some troubles with my VBA. its works fine, it does what I want. When I run it it creates seperate files out of all the sheets I want, But here is the problem, when creating seperate files the files contains links to formulas etc and that meeses things up, I want it to be created with values, no links, formulas etc. is it possible?
    below is my working code.
    thank you if anyone can help on how to fix this.

    Sub SplitEachWorksheet()
    Dim FPath As String
    Dim TexttoFind As String
    TexttoFind = "Sum"
    TexttoFind = "3"
    TexttoFind = "4"
    TexttoFind = "5"
    TexttoFind = "6"
    TexttoFind = "7"
    TexttoFind = "8"
    TexttoFind = "9"
    FPath = Application.ActiveWorkbook.Path
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False

    For Each ws In ThisWorkbook.Sheets
    If InStr(1, ws.Name, TexttoFind, vbBinaryCompare) <> 0 Then
    ws.Copy
    Application.ActiveWorkbook.SaveAs Filename:=FPath & "\" & ws.Name & ".xlsx"
    Application.ActiveWorkbook.Close False
    End If
    Next

    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
    End Sub

  2. #2
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: help Creating seperate files from existing sheets

    Before I read forward I've stopped here:
    Please Login or Register  to view this content.
    I do not get it? What value are you expect in TexttoFind?

    p.s. wrap code into CODE tag, please.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  3. #3
    Registered User
    Join Date
    02-12-2020
    Location
    Swe
    MS-Off Ver
    2016
    Posts
    15

    Re: help Creating seperate files from existing sheets

    Hi
    texttofind is any string in the sheetname Sum, 3 or 4 etc. thats the sheetnames it needs to create a separate file for.

  4. #4
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: help Creating seperate files from existing sheets

    But after all these lines TexttoFind="9", not "Sum", not "3", not "4", not "5" etc.

  5. #5
    Registered User
    Join Date
    02-12-2020
    Location
    Swe
    MS-Off Ver
    2016
    Posts
    15

    Re: help Creating seperate files from existing sheets

    Not sure what you mean, the Macro works properly it creates seperate files out the all the sheets I have. All I need this to do is create theese files with values in it, I don't want the original formulas in the cells to come with it. this is what I need help with to include a VBA in my code so when the separate files are created it is created with values in the cells and not formulas as in original sheet file.

  6. #6
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: help Creating seperate files from existing sheets

    Try like this:

    Please Login or Register  to view this content.
    should works.

  7. #7
    Registered User
    Join Date
    02-12-2020
    Location
    Swe
    MS-Off Ver
    2016
    Posts
    15

    Re: help Creating seperate files from existing sheets

    Strange after putting this in the macro button created wont even start to run the macro

  8. #8
    Registered User
    Join Date
    02-12-2020
    Location
    Swe
    MS-Off Ver
    2016
    Posts
    15

    Re: help Creating seperate files from existing sheets

    This is correct right?
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    02-12-2020
    Location
    Swe
    MS-Off Ver
    2016
    Posts
    15

    Re: help Creating seperate files from existing sheets

    No it didn't work, file created came with everywhere we had a formula it became #Value

  10. #10
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: help Creating seperate files from existing sheets

    No it is not. My bad.
    There is no Sum sheetname, you want to check if Sum is in name, so this way:

    Please Login or Register  to view this content.
    p.s. Could you edit your post instead of creating 3 in a row in few minutes, please?

  11. #11
    Registered User
    Join Date
    02-12-2020
    Location
    Swe
    MS-Off Ver
    2016
    Posts
    15

    Re: help Creating seperate files from existing sheets

    ok another problem in the code is that my sheetnames isn't exactly SUM, 3, 4 etc, it should look at the sheets containing those prefixes. how would the code look like then?

  12. #12
    Registered User
    Join Date
    02-12-2020
    Location
    Swe
    MS-Off Ver
    2016
    Posts
    15

    Re: help Creating seperate files from existing sheets

    yes exactly I want to check and see if the sheetname contains that. great I will try it.

  13. #13
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: help Creating seperate files from existing sheets

    Once more, please: Use Edit option. Do not comment your own post.

  14. #14
    Registered User
    Join Date
    02-12-2020
    Location
    Swe
    MS-Off Ver
    2016
    Posts
    15

    Re: help Creating seperate files from existing sheets

    Thank you this solved greatly the creating the files.
    sorry I am learning how all these buttons works.
    still having the issue when the file is created in those places there used to be a formula now gets #Value. the figures in those cells wont be pasted as values.

  15. #15
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: help Creating seperate files from existing sheets

    Checked attached file.
    3 sheets:
    Summary (should be created)
    Sheet1 (won't be created)
    Sheet99 (should be created)

    all of them has =rand() function in cells. But created 2 files (summary and sheet99) have values instead of.

    EDIT: I've got it now. After pasting into new workbook all references failed and gives errors. I'll tweak this.
    EDIT2: no. it works fine. attached sample of your file. There should be another type of issue.
    Attached Files Attached Files
    Last edited by KOKOSEK; 02-20-2020 at 11:47 AM.

  16. #16
    Registered User
    Join Date
    02-12-2020
    Location
    Swe
    MS-Off Ver
    2016
    Posts
    15

    Re: help Creating seperate files from existing sheets

    unfortunately I cannot attach the file public here as it contains business sensitive data.

  17. #17
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: help Creating seperate files from existing sheets

    Did you check attached file? Have sheets been created as expected with values?

  18. #18
    Registered User
    Join Date
    02-12-2020
    Location
    Swe
    MS-Off Ver
    2016
    Posts
    15

    Re: help Creating seperate files from existing sheets

    yes I checked it and it was great. exactly like that I would like my workbook to do.

    should I use the code in the file you sent?
    Last edited by tavakoli10; 02-20-2020 at 12:04 PM.

  19. #19
    Registered User
    Join Date
    02-12-2020
    Location
    Swe
    MS-Off Ver
    2016
    Posts
    15

    Re: help Creating seperate files from existing sheets

    this is how my file looks like when created. all the places there are formulas are displayed #valuetavakoli.jpg

    did the attachment work now?
    from row 44 and down the formulas are index formulas with some other things in it getting data from other sheets. is that maybe why it wont work, that the sheet is getting information from other sheets? what do think might be the problem?
    Last edited by tavakoli10; 02-21-2020 at 08:43 AM.

  20. #20
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: help Creating seperate files from existing sheets

    Quote Originally Posted by tavakoli10 View Post
    Attachment 663743

    this is how my file looks like when created. all the places there are formulas are displayed #value
    You have to reattach your file once more. Use Go Advanced / Manage Attachments option to upload file.

    p.s. Pal, please, please, do not comment your own posts. use EDIT option.

    EDIT: I've testes macro on sheet where are lots of weird formulas, everything goes smoothly, all has been created with values. So I think there is some error on your side. in your sheet)
    Last edited by KOKOSEK; 02-20-2020 at 12:57 PM.

+ 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. [SOLVED] Use of Loop Function for extracting data from Master sheet and creating seperate files
    By AnkitJain in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-17-2016, 04:10 AM
  2. [SOLVED] Macro that exports every X number of sheets into seperate files
    By Sgligori in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-22-2015, 12:03 PM
  3. loop through file creating seperate files depending on name in a column
    By papasmurfuo9 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-17-2015, 06:37 AM
  4. [SOLVED] Numbering ROWS sequentially on seperate sheets or files
    By Busybirds in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-27-2012, 12:40 PM
  5. VBA code to split sheets and save as seperate CSV files
    By mccrimmon in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-01-2008, 01:59 PM
  6. how do i open csv data files into seperate sheets ?
    By zohar81 in forum Excel General
    Replies: 0
    Last Post: 03-13-2008, 10:57 AM
  7. Splitting a workbook's sheets into seperate files
    By Turnipboy in forum Excel General
    Replies: 4
    Last Post: 10-20-2005, 10: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