+ Reply to Thread
Results 1 to 8 of 8

Splitting data into 5 sheets

Hybrid View

KLH2007 Splitting data into 5 sheets 06-07-2016, 07:17 PM
spitfireblue Re: First Time Macro Building... 06-07-2016, 07:25 PM
KLH2007 Re: First Time Macro Building... 06-07-2016, 10:07 PM
spitfireblue Re: Splitting data into 5... 06-08-2016, 01:10 AM
KLH2007 Re: Splitting data into 5... 06-08-2016, 09:10 AM
spitfireblue Re: Splitting data into 5... 06-08-2016, 09:40 AM
KLH2007 Re: Splitting data into 5... 06-08-2016, 10:42 AM
spitfireblue Re: Splitting data into 5... 06-08-2016, 06:20 PM
  1. #1
    Registered User
    Join Date
    06-07-2016
    Location
    atlanta ga
    MS-Off Ver
    Microsoft Office 10
    Posts
    4

    Splitting data into 5 sheets

    Hey Everyone!!

    I need to build a macro for excel to make my life easier. I've never done it and I am having a hard time figuring out how to get started. Could you point me in the right direction?

    I get lists of customers every month and I need to break them into 5 additional sheets, Customers with birthdays listed, Customers with birthdays and emails listed, customers with emails listed, customers with sales date listed and customers with no sales date listed.

    Thank you!!
    Attached Files Attached Files
    Last edited by KLH2007; 06-08-2016 at 09:09 AM.

  2. #2
    Valued Forum Contributor spitfireblue's Avatar
    Join Date
    01-29-2015
    Location
    Adelaide, Australia
    MS-Off Ver
    2007,2010,2016
    Posts
    611

    Re: First Time Macro Building Help

    Hi KLH2007,

    If you could please provide a sample file of the format of your data and also the format that you want it broken into we can help you.
    Also, I suggest that you update your title into something like "Splitting data into 5 sheets" (please see forum rule #1). This will be helpful for someone one who is google searching for a similar problem.
    Regards,
    Stephen

    If you feel someone has helped you please thank them and click on the star on their post to add reputation.
    Please ensure that you use code tags where relevant, and mark solved threads as solved.
    Most of all please be respectful and understanding of others.

  3. #3
    Registered User
    Join Date
    06-07-2016
    Location
    atlanta ga
    MS-Off Ver
    Microsoft Office 10
    Posts
    4

    Re: First Time Macro Building Help

    Thank you so much Stephen! I have updated the title and I went to add my example but the attachment feature is not working for me. I am going to try tomorrow morning when i get to work.

  4. #4
    Valued Forum Contributor spitfireblue's Avatar
    Join Date
    01-29-2015
    Location
    Adelaide, Australia
    MS-Off Ver
    2007,2010,2016
    Posts
    611

    Re: Splitting data into 5 sheets

    If you select "Go Advanced" then scroll down to Manage Attachments you can upload from there rather than using the paperclip (I believe there is some issues with this).

  5. #5
    Registered User
    Join Date
    06-07-2016
    Location
    atlanta ga
    MS-Off Ver
    Microsoft Office 10
    Posts
    4

    Re: Splitting data into 5 sheets

    Thank you!! That is what I needed. You are so helpful!

  6. #6
    Valued Forum Contributor spitfireblue's Avatar
    Join Date
    01-29-2015
    Location
    Adelaide, Australia
    MS-Off Ver
    2007,2010,2016
    Posts
    611

    Re: Splitting data into 5 sheets

    Try this:

    Sub Split()
        Dim lrow As Long
        Dim cell As Range
        Dim ws As Long
        Dim C2 As Long, C3 As Long, C4 As Long, C5 As Long, C6 As Long
        
        For ws = 2 To Sheets.Count
            With Sheets(ws)
                .Range("2:100").ClearContents
            End With
        Next
        
        C2 = 2
        C3 = 2
        C4 = 2
        C5 = 2
        C6 = 2
            
        Sheets(1).Activate
        lrow = Range("A" & Rows.Count).End(xlUp).Row
        
        For Each cell In Range("A2:A" & lrow)
            If Not cell.Offset(0, 8).Value = "" Then
                cell.EntireRow.Copy Destination:=Sheets(2).Range(C2 & ":" & C2)
                C2 = C2 + 1
            End If
            If Not cell.Offset(0, 9).Value = "" Then
                cell.EntireRow.Copy Destination:=Sheets(3).Range(C3 & ":" & C3)
                C3 = C3 + 1
            End If
            If Not cell.Offset(0, 2).Value = "" Then
                cell.EntireRow.Copy Destination:=Sheets(4).Range(C4 & ":" & C4)
                C4 = C4 + 1
            End If
            If Not cell.Offset(0, 2).Value = "" And Not cell.Offset(0, 3).Value = "" Then
                cell.EntireRow.Copy Destination:=Sheets(5).Range(C5 & ":" & C5)
                C5 = C5 + 1
            End If
            If Not cell.Offset(0, 3).Value = "" Then
                cell.EntireRow.Copy Destination:=Sheets(6).Range(C6 & ":" & C6)
                C6 = C6 + 1
            End If
        Next
    
    End Sub

  7. #7
    Registered User
    Join Date
    06-07-2016
    Location
    atlanta ga
    MS-Off Ver
    Microsoft Office 10
    Posts
    4

    Re: Splitting data into 5 sheets

    Thank you!!

    I am getting an error "run time error '9' subscript out of range"

    When I click Debug it highlights:

    cell.EntireRow.Copy Destination:=Sheets(4).Range(C4 & ":" & C4)


    What can I change to remove that error?

  8. #8
    Valued Forum Contributor spitfireblue's Avatar
    Join Date
    01-29-2015
    Location
    Adelaide, Australia
    MS-Off Ver
    2007,2010,2016
    Posts
    611

    Re: Splitting data into 5 sheets

    Hmm, I can't pick what the error is... here is the sheet that I used that isn't coming up with and error for me.
    Attached Files Attached Files

+ 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. Building an assembly time tracker
    By PHS8100 in forum Excel General
    Replies: 1
    Last Post: 04-20-2015, 11:49 AM
  2. building a revenue forecasting model and need calendar building help
    By miken33 in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 03-11-2013, 06:53 PM
  3. Formatting a total time entry and building a cumulative time formula.
    By TMc10 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-16-2012, 10:26 PM
  4. Replies: 2
    Last Post: 10-08-2012, 12:49 PM
  5. How to automate the date range when building Time-series charts in VBA
    By vbanewbie1233 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-14-2012, 08:11 AM
  6. building a chart to display time periods
    By Don Juan in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 11-21-2009, 07:31 AM
  7. calculate time in the building
    By jenn in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-07-2006, 03:05 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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1