+ Reply to Thread
Results 1 to 20 of 20

Gather data that don't exist from different worksheets to another workbook

  1. #1
    Registered User
    Join Date
    11-18-2019
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    80

    Gather data that don't exist from different worksheets to another workbook

    Hi,

    I'm having trouble with a macro aiming at gathering data that don't exist to another existing workbook.
    In my example, I have two sheets in the file "Input weeks". In each sheet, I have a list of weeks with a code for every days. If the week already exists in my database, then I get a code, but if it doesn't I want to add the new week created in my database "Catalogue weeks" at the end of the table to a new row.

    For instance, in the sheet "Mail 1": the week "J000;D139;JRHE;A041;A043;D137;D137" already exists and the code is E351.
    But the week "J001;J002;J003;J004;J005;J006;J007" does not exist and I would need to copy this week to the workbook "Catalogue weeks". Then, in the workbook "Catalogue weeks", I would give a code to this
    newly created week and I would need this new code to appear on the sheet "Mail 1".

    Last but not least, I can have several sheets named "Mail 1", "Mail 2", "Mail 3"... and I would need to loop accross all sheets.

    Could you please help me?

    If you have any question, feel free to ask.

    Many thanks!

    Okela
    Attached Files Attached Files
    Last edited by okela; 06-02-2020 at 02:10 PM.

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,028

    Re: Gather data that don't exist from different worksheets to another workbook

    In column J of Mail 1, Mail 2, Mail 3 …. will there ever be a description which is duplicated among all the sheets?
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    11-18-2019
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    80

    Re: Gather data that don't exist from different worksheets to another workbook

    Hi Mumps1,

    Yes, because this is generated thanks to the function TEXTJOIN.
    Thanks!

    Okela

  4. #4
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,310

    Re: Gather data that don't exist from different worksheets to another workbook

    Try...
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-18-2019
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    80

    Re: Gather data that don't exist from different worksheets to another workbook

    Hi dangelor!

    Many thanks! It's working really well, I would just need a small adjustement.
    In my case, I would need to manually define the code of the new week in the Workbook "Catalogue weeks" and then it would update the name in the sheet "Mail 1" for example.
    For example, the code of new week would not be E364 but AJ01.

    Do you think we can tweak it a little bit?

    Many thanks!!

    Okela

  6. #6
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,310

    Re: Gather data that don't exist from different worksheets to another workbook

    You could remove this line of code
    Please Login or Register  to view this content.
    then add your definition and then rerun the subroutine.

    ...or do you want the adding of the update as part of the subroutine?

  7. #7
    Registered User
    Join Date
    11-18-2019
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    80

    Re: Gather data that don't exist from different worksheets to another workbook

    Is this possible thanks to a VLOOKUP for instance? Ideally, I would need that once the code is entered on the Catalogue Weeks, the sheet "Mail 1" gets updated automatically.

  8. #8
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,310

    Re: Gather data that don't exist from different worksheets to another workbook

    Do you mean...?
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    You could but the code already does that, just in a different way with this...
    Please Login or Register  to view this content.

  9. #9
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,028

    Re: Gather data that don't exist from different worksheets to another workbook

    Are the codes in column A of Catalogue always sequential, that is E47, E348, E349 ….. ?

  10. #10
    Registered User
    Join Date
    11-18-2019
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    80

    Re: Gather data that don't exist from different worksheets to another workbook

    Quote Originally Posted by dangelor View Post
    Do you mean...?
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    You could but the code already does that, just in a different way with this...
    Please Login or Register  to view this content.
    Ok, I see! It means that I need to launch the macro twice?

  11. #11
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,310

    Re: Gather data that don't exist from different worksheets to another workbook

    Ok, I see! It means that I need to launch the macro twice?
    After you update the table, yes.

  12. #12
    Registered User
    Join Date
    11-18-2019
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    80

    Re: Gather data that don't exist from different worksheets to another workbook

    Hi Mumps1,
    No it can be really different. E500, A501, AA01... It has always 4 characters but it can be really different.

  13. #13
    Registered User
    Join Date
    11-18-2019
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    80

    Re: Gather data that don't exist from different worksheets to another workbook

    Ok great! Thanks dangelor!

  14. #14
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,028

    Re: Gather data that don't exist from different worksheets to another workbook

    If you are willing to let the macro generate the codes automatically and sequentially, try this macro in the Input_Weeks workbook. You will have to run it only once.
    Please Login or Register  to view this content.

  15. #15
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Try this demonstration !


    According to the attachment as a VBA beginner starter to paste to the inputs_weeks workbook
    (once the catalogue 'database' is updated run it again) :

    PHP Code: 
    Sub Demo1()
      Const 
    "Catalogue""_weeks.xlsx"
        
    Dim VLs As ListObjectWs As WorksheetRg As Range
            V 
    Evaluate("ISREF('[" "]" "'!A1)"):  IIf(IsError(V), FalseV):  If Not V Then Beep: Exit Sub
            
    If Workbooks(D).Worksheets(S).ListObjects.Count 0 Then Beep: Exit Sub
            Set Ls 
    Workbooks(D).Worksheets(S).ListObjects(1)
            
    Application.ScreenUpdating False
        
    For Each Ws In ThisWorkbook.Worksheets
            With Ws
    .Range("C4:I" Ws.[C3].End(xlDown).Row)
                     .
    Columns(9).Replace "?", Empty, xlWhole
                      Set Rg 
    = .Columns(9).Find(Empty, , xlValuesxlWhole)
                While 
    Not Rg Is Nothing
                           V 
    Application.Match(Rg(10), Ls.ListColumns(2).DataBodyRange0)
                If 
    IsError(VThen
                    Ls
    .ListRows.Add:  Ls.ListRows.Count
                    Ls
    .ListRows(V).Range.Columns("A:B") = Array("?"Rg(10))
                    
    Ls.ListRows(V).Range.Columns("C:I") = .Rows(Rg.Row 3).Value2
                End 
    If
                          
    Rg Ls.ListRows(V).Range(1).Value2
                      Set Rg 
    = .Columns(9).FindNext(Rg)
                
    Wend
            End With
        Next
            Application
    .ScreenUpdating True
            Set Ls 
    Nothing
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

  16. #16
    Registered User
    Join Date
    11-18-2019
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    80

    Re: Gather data that don't exist from different worksheets to another workbook

    Hi Mumps and Marc,

    Many thanks for your answers but I'll go with the solution provided by dangelor because it suits my needs and with my knowledge in VBA, I understand it better.

    Thanks once again!

    Okela

  17. #17
    Registered User
    Join Date
    11-18-2019
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    80

    Re: Gather data that don't exist from different worksheets to another workbook

    Dangelor,

    If I may, in my original file the catalogue actually starts at column B, could you please indicate me which line do I need to change?

    I would also need another tweak if possible. Once my weeks are created, I need to transpose the data to another sheet and create a new code (I have updated both examples accordingly).
    For example, in the sheet "Mail 1", the working cycle created is AA01 (it comes from the tab "Work cycle"). Could you please help me with that?

    Many thanks!

    Okela
    Attached Files Attached Files

  18. #18
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,310

    Re: Gather data that don't exist from different worksheets to another workbook

    If I may, in my original file the catalogue actually starts at column B, could you please indicate me which line do I need to change?
    This...
    Please Login or Register  to view this content.
    to...
    Please Login or Register  to view this content.
    For the rest, I think you should start a new thread.
    Last edited by dangelor; 06-02-2020 at 01:04 PM.

  19. #19
    Registered User
    Join Date
    11-18-2019
    Location
    Paris
    MS-Off Ver
    Office 2016
    Posts
    80

    Re: Gather data that don't exist from different worksheets to another workbook

    Thank you dangelor!

  20. #20
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,310

    Re: Gather data that don't exist from different worksheets to another workbook

    Glad to help!

+ 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. Gather data multiple sheets into 1 workbook
    By Nnex1996 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-22-2019, 03:37 AM
  2. macro to let user know if one of 5 worksheets do not exist in active workbook
    By ab8088 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-05-2016, 07:43 PM
  3. [SOLVED] Trying to use IF function to gather specific data from 2 worksheets
    By Womble2011 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-07-2012, 07:32 AM
  4. [SOLVED] VBA code to gather data from multiple worksheets in the same folder-Master List
    By lax2734 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-23-2012, 03:07 PM
  5. copying worksheets from one workbook to another and overwriting if they exist already
    By tinkerbelle in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-19-2010, 08:55 AM
  6. working with multiple worksheets to gather data
    By mrggutz in forum Excel General
    Replies: 4
    Last Post: 03-26-2010, 03:59 PM
  7. [SOLVED] Copy Worksheet to a new Workbook creating if it doesn't exist and add more Worksheets if it does exist
    By pete.bastin@btopenworld.com in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-18-2006, 01:10 PM

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