+ Reply to Thread
Results 1 to 8 of 8

Split data from Master Sheet to existing worksheets and overwrite data

  1. #1
    Registered User
    Join Date
    03-19-2013
    Location
    tampa, fl
    MS-Off Ver
    Excel 2010
    Posts
    4

    Split data from Master Sheet to existing worksheets and overwrite data

    Hi All,

    I'm new to macros and was hoping someone here could help me out. I'm currently using the code (found it on one of these forums) below to split data based on criteria in column A from a master workseet onto several existing worksheets (One tab for each salesman). This code works great but adds the data to the first non-blank row in the existing sheets. I would like for it to overwrite any data as this workbook is updated monthly and should only reflect current month activity. Any help would be greatly appreciated!!


    Please Login or Register  to view this content.
    Last edited by arlu1201; 03-21-2013 at 02:46 PM.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Split data from Master Sheet to existing worksheets and overwrite data

    Your code has lots of activate and select. These will slow down the code, specially if the data involves are large.
    Try this code. It does the same. I assumed that you want to copy from A4 H4 and headings are in A1-H1

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-19-2013
    Location
    tampa, fl
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Split data from Master Sheet to existing worksheets and overwrite data

    This works! My headers are in A1:H1 but I'd like to copy from A2:H2 if possible. Also, is there a way to add a subtotal for column H? Thanks so much!!

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Split data from Master Sheet to existing worksheets and overwrite data

    vmwest,

    Welcome to the forum.

    I have added code tags to your post. As per forum rule 3, you need to use them whenever you put any code in your post. Please add them in future. If you need more information on how to use them, check my signature below this post.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  5. #5
    Registered User
    Join Date
    03-19-2013
    Location
    tampa, fl
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Split data from Master Sheet to existing worksheets and overwrite data

    Ok, I changed i = 2 and that updated the copy range to A2:H2 as desired. But I just ran into a new issue. I have other sheets (besides the master & existing salesman tabs) in this workbook that were cleared of data when I ran the macro. These are cumulative summary sheets that shouldn't be affected by the macro. I noticed at the end of the code there was Then ws. Delete. Is this what's causing that?

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Split data from Master Sheet to existing worksheets and overwrite data

    No, sometimes the name is not valid one, so instead of showing an error, I let it go and the code will create blank sheet1,2 and so on if the cell value is not valid name.
    You need to change this line of the code

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.
    Then

    So, add to the above the name of the sheet which you wish to exclude, but you can delete that line if you do not want to

    Please Login or Register  to view this content.
    ' the whole line should be deleted

  7. #7
    Registered User
    Join Date
    03-19-2013
    Location
    tampa, fl
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Split data from Master Sheet to existing worksheets and overwrite data

    What a beautiful thing! Works perfect! Thank You!!

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Split data from Master Sheet to existing worksheets and overwrite data

    Vmwest,
    You are welcome!
    If you are happy with the solution provided, please close this thread.
    Go in to the top right -hand of this page, choose "Thread Tools" from the menu, then solved from the drop down menu

+ 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