+ Reply to Thread
Results 1 to 2 of 2

creating individual databases from smaller ones

Hybrid View

  1. #1
    Registered User
    Join Date
    07-11-2012
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    9

    creating individual databases from smaller ones

    Hey everyone, I posted in the other forum and just wanted to link it in here too to see if anyone has any wisdom they could share with me. The question/situation is explaining in the first post on the link.

    thank you very much!

    http://www.excelforum.com/excel-gene...51#post2854751

    **I would like to add also that I will be making this workbook but it will be someone else who will be using it in the future. I will not be present so, ideally, whatever function I end up using can be easily repeated by someone without the same expertise.
    Last edited by blubberbo; 07-11-2012 at 06:12 PM.

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: creating individual databases from smaller ones

    Probably you get the solution with the link below.

    http://www.excelforum.com/excel-gene...o-each-ws.html

    Sub Split_Worksheets()
    Dim rRange As Range, rCell As Range
    Dim wSheet As Worksheet
    Dim wSheetStart As Worksheet
    Dim strText As String
    
     Set wSheetStart = ActiveSheet
     wSheetStart.AutoFilterMode = False
     'Set a range variable to the correct item column
     Set rRange = Range("A1", Range("A65536").End(xlUp))
    
         'Delete any sheet called "UniqueList"
         'Turn off run time errors & delete alert
         On Error Resume Next
         Application.DisplayAlerts = False
         Worksheets("UniqueList").Delete
    
         'Add a sheet called "UniqueList"
         Worksheets.Add().Name = "UniqueList"
    
            'Filter the Set range so only a unique list is created
             With Worksheets("UniqueList")
                  rRange.AdvancedFilter xlFilterCopy, , _
                  Worksheets("UniqueList").Range("A1"), True
    
                  'Set a range variable to the unique list, less the heading.
                  Set rRange = .Range("A2", .Range("A65536").End(xlUp))
             End With
    
             On Error Resume Next
             With wSheetStart
                 For Each rCell In rRange
                   strText = rCell
                   .Range("A1").AutoFilter 1, strText
                     Worksheets(strText).Delete
                     'Add a sheet named as content of rCell
                     Worksheets.Add().Name = strText
                     'Copy the visible filtered range _
                     (default of Copy Method) and leave hidden rows
                     .UsedRange.Copy Destination:=ActiveSheet.Range("A1")
                     ActiveSheet.Cells.Columns.AutoFit
                 Next rCell
             End With
    
         With wSheetStart
             .AutoFilterMode = False
             .Activate
         End With
    
         On Error GoTo 0
         Application.DisplayAlerts = True
    End Sub
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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