+ Reply to Thread
Results 1 to 12 of 12

Auto copy part of row in a worksheet to another worksheet based on criteria

  1. #1
    Registered User
    Join Date
    05-25-2004
    Posts
    30

    Auto copy part of row in a worksheet to another worksheet based on criteria

    Hello, I'm a novice Excel 2007 user and appreciate all the help I can get. I have a workbook with monthly worksheets in it. When a certain data Type is selected from a drop down menu in that monthly worksheet than I would like to have it automatically enter specific data (Name, Date, Eval, Type) copied to another worksheet (CC) in the same workbook. I have been manually entering the data so far. Another thing, some of the data will be entered into the Monthly worksheets and some will only be manually entered into the CC worksheet so it would need to accomodate both methods of data entry. Please let me know if I need to clarify. I have attached the workbood, too. Thanks again so much for your help!
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Auto copy part of row in a worksheet to another worksheet based on criteria

    Right-click on the Excel logo to the left of the FILE menu and select VIEW CODE...paste in this workbook event macro:

    Please Login or Register  to view this content.
    Exit the Editor and save your workbook.

    Now any changes on any of the monthly sheets in the "Offense" columns will transfer to the CCs sheet if they are CC offenses.
    Last edited by JBeaucaire; 12-15-2009 at 04:54 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    05-25-2004
    Posts
    30

    Re: Auto copy part of row in a worksheet to another worksheet based on criteria

    Hi, I tried pasting the code into this workbook but it didn't work. I'm not sure what I'm doing wrong. Do I need to run the macro? I realize these are basic questions, my apologies. Also, how does the date get entered? Thanks again!!

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Auto copy part of row in a worksheet to another worksheet based on criteria

    Post up your amended workbook with the macro installed so I can see what's going on with your attempt. You do know you will have to save the workbook as a .xlsm and then reopen the workbook for it to work, right?

    The Date is being taken from the section the *-CC code is entered. The macro looks at the top of each section in the "merged" cell and transfers what it finds there. It's working good in my testing.

  5. #5
    Registered User
    Join Date
    05-25-2004
    Posts
    30

    Re: Auto copy part of row in a worksheet to another worksheet based on criteria

    I copied and pasted the macro and have attached the file, I' new to macros so it is likely I missed a basic step. Any help would be greatly appreciated!
    Attached Files Attached Files
    Last edited by repke; 01-04-2010 at 11:02 PM. Reason: Solved - my apologies I couldn't seem to edit the first post

  6. #6
    Registered User
    Join Date
    05-25-2004
    Posts
    30

    Re: Auto copy part of row in a worksheet to another worksheet based on criteria

    I don't know what I did to get it to work. Thank you! I really appreciate it. Now I have another question. There are actually more worksheets in the real version of the workbook so how do I change the code to refer to these worksheets? Also, can code be added to modify/delete the item in the CCs worksheet when it is modified/deleted on one of the sheets it is pulled from?

    Here are the actual sheets that contain the data that I'd like to have copied: Sheet1, Sheet10, Sheet12, Sheet14, Sheet 16, Sheet19, Sheet21, Sheet 23, Sheet25, Sheet4, Sheet6, Sheet8. The CCs sheet is actually Sheet29.

    Thanks again!! I really appreciate all the help!

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Auto copy part of row in a worksheet to another worksheet based on criteria

    1) Remove the code from the CCs sheet. As indicated above, the macro provided goes in ThisWorkbook module only. I see it is in that module, too, and workgin properly.

    2) Move the CCs worksheet so that it is the first sheet in the workbook, just like your example workbook. The macro is using the Sheet.Index values to decide if the data should be copied, so make sure the sheets occupy index positions 2-13. The sheet names are not used.

    4) To have the macro refer to MORE sheets than those 12, put them all together from position 2 through "whatever" and then change the one line of code here to indicate the correct beginning and ending range of the sheet index positions:
    Please Login or Register  to view this content.

    4) Move your sheets listed in post #6 so they are AFTER the sheets above.

    The macro should continue to work just fine.
    Last edited by JBeaucaire; 01-04-2010 at 02:51 AM.

  8. #8
    Registered User
    Join Date
    05-25-2004
    Posts
    30

    Re: Auto copy part of row in a worksheet to another worksheet based on criteria

    Thanks, but the difficulty I have is that for each month I two worksheets and they are placed one after the other for the year... Jan2010, Jan2010S, Feb2010, Feb2010S, etc. The Sheet names I listed in post 6 are from the code in the writer (not the name I have in the workbook). So I was hoping there was a way to refer to the Sheets listed in post 6 specificially regardless of the order. Also, is there a way to change the code so that it will modify/delete the information in the CCs sheet if it is modified/deleted in the other worksheets (e.g., Jan2010)?

    Thanks again! Really appreciated!!

  9. #9
    Registered User
    Join Date
    05-25-2004
    Posts
    30

    Re: Auto copy part of row in a worksheet to another worksheet based on criteria

    I didn’t know what it meant to use a Sheet.Index value so I looked it up and from what I read it seems like a Sheets Code Name might be the best way to go with this workbook. How would I change the code to a Sheets Code Name? So would I change your line like this? Or do I use Sheet1.Select? Are there other lines that need to be changed? Also, is there a way to code it so that the data in the CCs sheet is automatically modified/deleted in the other sheets? Thanks for all your time and help!! I really appreciate it.

    'Certain changes in every 4th column of sheets2-13 transfer to data to sheet1

    'Certain changes in every 4th column of sheet1,sheet10,sheet12,sheet14,sheet16,sheet19,sheet21,sheet23,sheet25,sheet4,sheet6,sheet8 transfer to data to sheet29

    I attached a document showing the editor names for the sheets, hopefully this will show it better than I'm explaining. Thanks again!
    Attached Files Attached Files

  10. #10
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Auto copy part of row in a worksheet to another worksheet based on criteria

    This should do it, list the sheet names in the highlighted section...this way it won't matter where they are in the workbook, as long as you list them by name accurately, they will trigger the transfer macro.
    Please Login or Register  to view this content.
    I have no ideas for allowing you to edit entries already transferred.

  11. #11
    Registered User
    Join Date
    05-25-2004
    Posts
    30

    Re: Auto copy part of row in a worksheet to another worksheet based on criteria

    Thanks!! It worked. I really appreciate it.

  12. #12
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Auto copy part of row in a worksheet to another worksheet based on criteria

    If that takes care of your need, be sure to EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].

    If the PREFIX box is no longer available, just add [SOLVED] to the start of the title...

+ 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