+ Reply to Thread
Results 1 to 26 of 26

Conditional copy of specific cells to another sheet

  1. #1
    Registered User
    Join Date
    07-28-2010
    Location
    princeton, nj
    MS-Off Ver
    Excel 2003
    Posts
    13

    Conditional copy of specific cells to another sheet

    there are a few threads related to conditional copy but none are addressing the issue I have.

    Have a master sheet , Would like to copy specific column values ( along with the cell formating) to another sheet in the same workbook if there is a "X" in a specific column.

    there are multiple columns with X to be copied to mutiple worksheets

    Sample file attached
    For example Would like to copy from Master sheet to a sheet "Ent App" columns Number and Title based on the "X" in the column Ent App.Would like the formating of the cells to be the same as in the master sheet after copying.
    Same for all other columns in the worsheet.


    this is the first time with excel macros....Any help appreciated.
    Attached Files Attached Files

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Conditional copy of specific cells to another sheet

    Hi Anra

    Try this code
    Please Login or Register  to view this content.
    Let me know of issues.

    John
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    07-28-2010
    Location
    princeton, nj
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Conditional copy of specific cells to another sheet

    Thanks so much..just ran on the sample data and works perfectly..I will try it out on the real data and will let you know. Thanks again

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Conditional copy of specific cells to another sheet

    Hi Anra

    Yes please. Let me know how it goes.

    John

  5. #5
    Registered User
    Join Date
    07-28-2010
    Location
    princeton, nj
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Conditional copy of specific cells to another sheet

    Hi John - It works great on the real data!! Thank you!!

    I'm embedding each worksheet on to a ppt and could you pl let me know how to add to this script -
    when a new sheet is created with filtered data it automatically updates the sheet ( as it does now)
    & also creates a new file and updates the same data.

    So each filter will have 1 sheet + 1new file

    Example : From master sheet we have created "Ent App" sheet (happening now with filtered contents) in addition to this create a new file and add a sheet "Ent App" with the same filtered content.

    Is this possible? Any help on this will be great...thanks!

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Conditional copy of specific cells to another sheet

    Hi Anra

    A couple of things. I've no idea what this is
    a ppt
    Secondly, if I understand you correctly, you wish to filter the data for "Ent App" to it's worksheet as the code does now. Then you wish to create a new workbook called "Some Thing" that will have a worksheet in it called "Ent App". This new "Ent App" worksheet will contain the same data as the original copy of "Ent App". Is my understanding correct?

    John

  7. #7
    Registered User
    Join Date
    07-28-2010
    Location
    princeton, nj
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Conditional copy of specific cells to another sheet

    Yes that is correct and ppt - was power point..sorry

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Conditional copy of specific cells to another sheet

    Hi Anra

    I think this code does as you requested
    Please Login or Register  to view this content.
    Please note there are two procedures here and they should both go in the same module. Also note that I've changed the previous code slightly so you'll need to replace it also. The code is in the attached.

    Let me know of issues.

    John
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    07-28-2010
    Location
    princeton, nj
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Conditional copy of specific cells to another sheet

    Many Thanks John..tried it out with my actual data and it works great!!

    Some Files created are large with many rows..would it be possible to add some condition
    to say that when the row count in the newly created file exceeds say 50 (testing purposes) to create
    a new file which has header row + rows that are greater than 50...

    No changes to the tab sheets created by the macro..just the files should add the confition

  10. #10
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Conditional copy of specific cells to another sheet

    Hi Anra

    Glad it works for you.

    Regarding this
    Some Files created are large with many rows..would it be possible to add some condition
    to say that when the row count in the newly created file exceeds say 50 (testing purposes) to create
    a new file which has header row + rows that are greater than 50...
    Are you saying that if in a new file to be created, the Row Count is going to be more that 50, then create a second file and split the file into two files? If this is the case, submit a file that exceeds row count of 50 to give me a file to test against.

    John
    Last edited by jaslake; 07-30-2010 at 07:19 PM.

  11. #11
    Registered User
    Join Date
    07-28-2010
    Location
    princeton, nj
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Conditional copy of specific cells to another sheet

    Hi John - thats correct. Attached are 2 file. Sample file with apx 150 rows ( master file ) and another file Ent App.xls both for test... thanks a bunch
    Attached Files Attached Files

  12. #12
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Conditional copy of specific cells to another sheet

    Hi Anra

    I'm traveling this weekend and next week. I'll have some but not much spare time. I'll look at this possibility for you. What would the second Ent App file be called...perhaps Ent App 1?

    John

  13. #13
    Registered User
    Join Date
    07-28-2010
    Location
    princeton, nj
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Conditional copy of specific cells to another sheet

    yes..that should be fine. if there are 140 rows for example..would like it to create 3 files Ent App1( 50 rows ) Ent App2 ( 50 rows) Ent App3 ( 40 rows). thank you!

  14. #14
    Registered User
    Join Date
    07-28-2010
    Location
    princeton, nj
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Conditional copy of specific cells to another sheet

    Hi John - would appreciate any help on the rowcount section. Have no macro experience...I tried doing it myself and it started to mess with the existing code...please help

    Thank you so much for all the help so far, I ran the macro on the final data set and it ran perfectly... Thank you!!

  15. #15
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Conditional copy of specific cells to another sheet

    Hi Anra

    Sorry I haven't gotten back to you. I've been working with my son, daughter-in-law and two grandsons with their new home. Been working 10 hour days and haven't had the clarity of mind to work on your solution.

    Going home on Thursday and will address your issue this weekend.

    John

  16. #16
    Registered User
    Join Date
    07-28-2010
    Location
    princeton, nj
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Conditional copy of specific cells to another sheet

    Hi John, Thank you!!

  17. #17
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Conditional copy of specific cells to another sheet

    Hi Anra

    I've had this issue sorta surrounded several times. Still trying to nail down the problem of adding data to more that two sheets. Haven't given up as yet. Still working on it.

    John

  18. #18
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Conditional copy of specific cells to another sheet

    Hi Anra

    I've about gotten this sorted out. I have company this weekend but I'll try to post something late tomorrow or early Monday.

    John

  19. #19
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Conditional copy of specific cells to another sheet

    Hi Anra

    This code is included in the attached workbook. It appears to do as you requested.
    Please Login or Register  to view this content.
    and
    Please Login or Register  to view this content.
    I don't believe I've changed the first procedure but I won't guarantee it. The second procedure has been changed to accommodate this
    if there are 140 rows for example..would like it to create 3 files Ent App1( 50 rows ) Ent App2 ( 50 rows) Ent App3 ( 40 rows)
    Try it and see if it does as you require. You can modify the procedure quite easily to do more or less than 50 rows. Simply change the 50's to "Whatever" and the 49's to one less that "Whatever".

    Let me know of issues.

    John
    Attached Files Attached Files

  20. #20
    Registered User
    Join Date
    07-28-2010
    Location
    princeton, nj
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Conditional copy of specific cells to another sheet

    Will try and let you know..Thank you so much !

  21. #21
    Registered User
    Join Date
    07-28-2010
    Location
    princeton, nj
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Conditional copy of specific cells to another sheet

    Hi John - Its been a while..got pulled into another project and could not try and get back. Apologies.
    I ran the code I'm getting a debug error on the variable LR...
    Can you please help me ? thanks so much.

  22. #22
    Registered User
    Join Date
    07-28-2010
    Location
    princeton, nj
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Conditional copy of specific cells to another sheet

    LR = bk.Worksheets(ws.Name).Range("A" & Rows.Count).End(xlUp).Row - this line and also the heading colors are not geting copyed to the newly created spread sheets...

    thanks again

  23. #23
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Conditional copy of specific cells to another sheet

    Hi Anra

    It has been a while. I've trashed your folder so will need to work with the file attached to your thread.

    1. The worksheet runs fine on my machine. What error message are you getting?

    2. I'm color blind but my headings don't appear to have colors

    Please do this. Upload the file you're using (with appropriate colors) and with the code. I'll take a look at it.

    John
    Last edited by jaslake; 10-22-2010 at 04:29 PM.

  24. #24
    Registered User
    Join Date
    07-28-2010
    Location
    princeton, nj
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Conditional copy of specific cells to another sheet

    Hi John, File Attached.
    1. the Macro is also in the file. I have currently set the row count to 20.
    When I get passed the error with LR, the files are getting created works great.
    2. Would like the headings/color coded rows to pick up the master file color coding.
    IT151.xls is the file that was generated. i would like the file to look like IT151-sample.xls
    - with the heading color picked up from MASTER sheet.

    thanks so much, sorry for not being clear.
    Anra
    Attached Files Attached Files

  25. #25
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Conditional copy of specific cells to another sheet

    Hi Anra

    I've tested the code in Excel 2000 and Excel 2007 and I can't get this line of code to throw an error
    Please Login or Register  to view this content.
    What is the error message you're getting?

    John

  26. #26
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Conditional copy of specific cells to another sheet

    Hi Anra

    I've tested the attached quite thoroughly in Excel 2000 and 2007. I've not been able to duplicate the error you mentioned. If you still get the error, I'll need to know what the error message says.

    I've added this line of code
    Please Login or Register  to view this content.
    If you wish to change the number of lies in each file, change it here.

    I'll also point out, you need to run the Update procedure first. This procedure calls AddBook.

    Let me know of issues.

    John
    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)

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