+ Reply to Thread
Results 1 to 15 of 15

Clear dynamic named sheet, compare cells from 2 sheets, copy all matched rows to dynamic s

  1. #1
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Clear dynamic named sheet, compare cells from 2 sheets, copy all matched rows to dynamic s

    Hello all. I need some help to clear a dynamically named sheet, compare cells from 2 sheets, copy all matched rows to the dynamically named sheet. I have attached the test worksheet. I can copy specifically designated cells from one sheet to another but the matching and then copying is eluding me. I have looked at many Forum examples but nothing so far has looked like it would do what I need.

    Specifically, the code currently creates sheets dynamically. Once the sheet is created, I need the entire associated rows from "1_Imported" column "A" that match the cells on "ZZ_Maintenance" column "D" to be copied to the dynamically named sheet in "A5". If the sheet already exists, the used rows from "A5" down need to be cleared first, then the new rows pasted in "A5". My production spreadsheet currently has over 550 sheets so after the initial creation, creating new sheets will not occur very often, so the clearing before pasting is what will normally occur.

    Thanks in advance!!
    Andrew
    Attached Files Attached Files
    Last edited by drewship; 12-14-2015 at 09:46 AM.

  2. #2
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: Clear dynamic named sheet, compare cells from 2 sheets, copy all matched rows to dynam

    Trying to use the following code to compare the current value of column "D" on the ZZ_Maintenance sheet to the values of column "A" on the 1_ImportedData sheet. It compares and copies but only the first instance and the specified range on the 1_ImportedData sheet. The range needs to be dynamic and the compare needs to check each row.

    Please Login or Register  to view this content.
    Can someone change this to check each row on 1_ImportedData and copy/paste the corresponding data, or post a better solution?
    Last edited by drewship; 12-14-2015 at 12:42 PM.

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

    Re: Clear dynamic named sheet, compare cells from 2 sheets, copy all matched rows to dynam

    I am trying to adjust your code. There are many unnessary lines need to me removed, but should this line be

    Please Login or Register  to view this content.
    You are searching the same sheet

  4. #4
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: Clear dynamic named sheet, compare cells from 2 sheets, copy all matched rows to dynam

    This should be comparing 2 columns on the same sheet...wsMain is my helper sheet (EDIT) and is used to associate a name to a customer number so is being used for a different part of the overall code.

    Please Login or Register  to view this content.
    This should be comparing column "A" on my imported data sheet (wsData)to column "D" on my helper sheet (wsMain). Every row on the data sheet that matches the current value of the "D" column on the helper sheet needs to be copied to the current "shtName".

    Please Login or Register  to view this content.
    I am trying to figure this out using forum code and trying differrent things so my code probably isn't very good. If there are better ways to accomplish this that would be great.
    Last edited by drewship; 12-14-2015 at 01:19 PM.

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

    Re: Clear dynamic named sheet, compare cells from 2 sheets, copy all matched rows to dynam

    See if this what you are after. Even though I have copied the hyperlink lines from your code, for unknown reason to me, they are not working. I am sure you can adjust these lines in my code.
    Attached Files Attached Files

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

    Re: Clear dynamic named sheet, compare cells from 2 sheets, copy all matched rows to dynam

    Slightly amended.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: Clear dynamic named sheet, compare cells from 2 sheets, copy all matched rows to dynam

    Thanks AB33! I think a couple of tweaks and this will work. The reason the hyperlinks are not working is because there cannot be any spaces between the names, that is why there were 2 sections of code used to create the sheets. One section replaced " " with "_" for names having spaces so the hyperlinks worked, the other section was for single word names.

    The code works fine for clearing and copying the first time run, but if you run it again, the clear part of the code also clears the hyperlink to the Summary sheet and the name that was in A2. Is there a way to clear from A5 and not the entire sheet?

    It looks like your code will save me from having to sort everything on the Imported Data sheet first so thank you!!

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

    Re: Clear dynamic named sheet, compare cells from 2 sheets, copy all matched rows to dynam

    That is easy bit,
    Change the clearing line in to
    FROM
    Please Login or Register  to view this content.
    INTO

    Please Login or Register  to view this content.
    Can you adjust the hyperlink?

  9. #9
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: Clear dynamic named sheet, compare cells from 2 sheets, copy all matched rows to dynam

    Yep, I am working on that now and I think I can get that working again. My coding may not be as elegant as everyone else's, but if it works, I am ok with it. Thanks!!

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

    Re: Clear dynamic named sheet, compare cells from 2 sheets, copy all matched rows to dynam

    I believe this one works.
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: Clear dynamic named sheet, compare cells from 2 sheets, copy all matched rows to dynam

    This is what I had...much longer than yours(even without the few extra housekeeping lines)...I like yours better!!
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: Clear dynamic named sheet, compare cells from 2 sheets, copy all matched rows to dynam

    Both yours and mine work as needed but yours is easier to follow...thanks again!

  13. #13
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: Clear dynamic named sheet, compare cells from 2 sheets, copy all matched rows to dynam

    I will test tomorrow on my production data and will solve this thread if all goes well.

  14. #14
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: Clear dynamic named sheet, compare cells from 2 sheets, copy all matched rows to dynam

    After a few minor modifications, this is working on my production data as desired, thanks again AB33!!
    Attached Files Attached Files

  15. #15
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: Clear dynamic named sheet, compare cells from 2 sheets, copy all matched rows to dynam

    Ok...I spoke too soon. The problem is that some of the names are 3 or more words so since the code only creates the sheet with the first 2 names, any similar names after will cause the code to overwrite the original sheet. How do I modify

    Please Login or Register  to view this content.
    so it will replace all the spaces between all the words with "_"? (EDIT) Examples: Richard John Willams, Richard John Willams1, Richard John Willams2, Richard John Willams Jones
    Last edited by drewship; 12-15-2015 at 12:37 PM.

+ 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. Dynamic Copy Range All Sheets to One Sheet
    By jonathann3891 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-29-2015, 08:26 AM
  2. Copy dynamic specified, filtered cells/range from one sheet to multiple sheets
    By szeconku in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-22-2015, 06:14 AM
  3. VBA- Macro for copy and paste of dynamic info in certain sheets into summary sheet
    By Theresa.L.Waysone in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-25-2014, 04:55 PM
  4. [SOLVED] clear dynamic named range content
    By intex in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-12-2014, 08:29 AM
  5. [SOLVED] Compare 2 sheets, match data in 1 column, update row in sheet 2 & add new rows not matched
    By Synchronicity in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 11-11-2013, 01:21 PM
  6. Copy and Pasting dynamic data into blank rows and of another sheet
    By Lisa4legin in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 06-18-2013, 07:49 PM
  7. Match two Columns of two Sheets and Copy Matched Rows to a Third Sheet
    By Par in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-08-2012, 10:16 AM

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