+ Reply to Thread
Results 1 to 2 of 2

Splitting an Excel File into Multiple Sheets but retaining lookup data etc

  1. #1
    Registered User
    Join Date
    08-21-2013
    Location
    Bristol, England
    MS-Off Ver
    Excel 2010
    Posts
    2

    Splitting an Excel File into Multiple Sheets but retaining lookup data etc

    Any help on this would be appreciated - I couldn't find anything quite like this already that I could use:

    I have a master expenses file that has a page for each employee summarising their expenses. The employee sheets run off array formulas and lookups from hidden data sheets.

    I want to send each employee a copy of their expenses with the lookups etc hidden but still in tact so that they can complete the coding etc using lookup lists (project and expense codes) from the data sheets.

    What I envisage is a macro create to a set of individual employee files with only their page but with the lookups and data in remaining in tact and hidden in each. I've been trying to create a macro to systematically work through the file creating new files for each employee deleting each of the other employee sheets but retaining the hidden data and related lookups - with no success

  2. #2
    Registered User
    Join Date
    08-21-2013
    Location
    Bristol, England
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Splitting an Excel File into Multiple Sheets but retaining lookup data etc

    This is as far as I have got. I've named the hidden sheets I want to retain "Hide-xxxxx" but the And function isn't working it is deleting everything not just the unhidden sheets

    The other problem is the copy retains formula links to the original workbook not to the hidden sheets in the new version (if they were there!)...

    --------------------------------------------------------

    Sub SplitFile()

    Dim wb As Workbook
    Dim NewBook As Workbook
    Dim ws As Worksheet
    Dim ws2 As Worksheet

    Application.ScreenUpdating = False
    Application.DisplayAlerts = False

    Set wb = ThisWorkbook

    For Each ws In wb.Worksheets
    If ws.Visible = xlSheetVisible Then
    Set NewBook = Workbooks.Add
    With NewBook
    .Title = ws.Name
    ws.Copy After:=NewBook.Worksheets("Sheet3")

    For Each ws2 In NewBook.Worksheets
    If ws2.Name <> ws.Name And Left(ws2.Name, 4) <> "Hide" Then
    ws2.Delete
    End If
    Next
    .SaveAs ws.Parent.Path & "\" & ws.Name
    .Close
    End With
    End If
    Next

    wb.Activate

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

+ 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. Splitting Data from 1 Sheet to Multiple Existing Sheets
    By cloud19 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-29-2013, 03:52 PM
  2. Splitting Excel sheet into multiple sheets
    By wern477 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-01-2011, 05:05 PM
  3. VBA to merge multiple Workbooks with multiple sheets retaining headers
    By LauraN1 in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 08-19-2010, 03:47 PM
  4. Splitting a Text File and importing into multiple excel files
    By DhavokD in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-28-2009, 02:44 PM
  5. Splitting columns by , and retaining orginal row information
    By tjquinn in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-22-2008, 08:11 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