Results 1 to 3 of 3

Thread: How to build a Macro which can split data among Worksheets in Excel

  1. #1
    Join Date
    Jan 2012
    Posts
    24

    How to build a Macro which can split data among Worksheets in Excel

    I would like to create a macro that will automatically create a worksheet based on name. For example, if I have a file of sales data by sales rep, how can I create an individual worksheet for each sales rep without copying and pasting the data.

  2. #2
    Join Date
    May 2011
    Posts
    410

    Re: How to build a Macro which can split data among Worksheets in Excel

    Try the following code, this might help you :
    Code:
    Sub addshets()
    For Each c In Range("a2:a5")
    On Error Resume Next
    Sheets.Add after:=Sheets(Sheets.Count): ActiveSheet.Name = c
    Next c
    End Sub

  3. #3
    Join Date
    Aug 2011
    Posts
    695

    Re: How to build a Macro which can split data among Worksheets in Excel

    I am not sure about splitting the data among different worksheets, but I can provide a Macro which can help you to split data among columns. Hope by modifying it you can

    get the result which you are expecting.
    Code:
    Range ("A1"). Select 
     Application.ScreenUpdating = False 
     'Running the macro 
     Do While Not IsEmpty (ActiveCell) 
     "First we look at which cell we are, 
     'To return to her once tidy row 
     dondeestoy = ActiveCell.Address 
     'Decompose the string into substrings, 
     'To which indicate the delimiter "#" 
     ActiveCell = Replace (ActiveCell, "/", "#") 
     'ActiveCell = Replace (ActiveCell, "'", "#") 
     'ActiveCell = Replace (ActiveCell, "" "" "#") 
     data = Split (ActiveCell, "#") 
     For i = 0 To UBound (data) 
     'We each data array in a column 
     ActiveCell = data (i) 
     'We move to the adjacent column (at right) 
     ActiveCell.Offset (0, 1). Select 
     Next 'continue with the loop 
     'We are back where we were initially 
     Range (dondeestoy). Select 
     'Pass to the next row, and go back to the loop 
     ActiveCell.Offset (1, 0). Select 
     Loop 
     'Show all over again 
     Application.ScreenUpdating = True 
     End Sub

Similar Threads

  1. Need a Macro to copy data from Excel to a Application
    By NardO in forum MS Office Support
    Replies: 7
    Last Post: 12-04-2012, 10:20 PM
  2. Replies: 2
    Last Post: 22-01-2012, 11:59 AM
  3. Replies: 8
    Last Post: 04-12-2011, 11:24 AM
  4. Compare two Excel Worksheets on Mac
    By Claudius in forum Windows Software
    Replies: 2
    Last Post: 10-06-2009, 10:46 PM
  5. What is Workbook and Worksheets in Excel
    By Xylina in forum Windows Software
    Replies: 3
    Last Post: 06-06-2009, 07:13 PM

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
  •  
Page generated in 1,713,448,217.39515 seconds with 17 queries