+ Reply to Thread
Results 1 to 14 of 14

Fill a sheet with data from three different sheets, same workbook, in a very tricky way

  1. #1
    Registered User
    Join Date
    09-23-2019
    Location
    Ghana
    MS-Off Ver
    2016 32 bit and 64 bit
    Posts
    92

    Fill a sheet with data from three different sheets, same workbook, in a very tricky way

    Cross posted at:
    https://www.mrexcel.com/board/thread...y-way.1120503/




    I have this challenge here again.

    I am pulling data from three sheets: "Group 1", " Group 2" and "Group 3".

    My goal is to have the data from all three sheets displayed on another sheet as shown in the sample workbook

    Reason for cross posting:
    It has been a few days without solution
    Last edited by Pepe Le Mokko; 01-20-2020 at 04:03 AM. Reason: Removed external link to file

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: Fill a sheet with data from three different sheets, same workbook, in a very tricky wa

    Hi
    please post your sheet on the forum ( see yellow banner)
    External links are notoriously unsafe
    Thank you

  3. #3
    Registered User
    Join Date
    09-23-2019
    Location
    Ghana
    MS-Off Ver
    2016 32 bit and 64 bit
    Posts
    92

    Re: Fill a sheet with data from three different sheets, same workbook, in a very tricky wa

    Here we go:
    Attached Files Attached Files

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

    Cool Hi ! Try this !


    With the item entry in OUT_PUT_DATA!B1 cell,

    a VBA beginner starter demonstration to paste to the (OUT_PUT_DATA) worksheet module :

    PHP Code: 
    Private Sub Worksheet_Change(ByVal Target As Range)
        
    Dim KHLN&, VR&, C%
            If 
    Target.Address <> "$B$1" Then Exit Sub
            Application
    .EnableEvents False
            Me
    .UsedRange.Offset(1).Clear
            
    If IsEmpty(TargetThen Application.EnableEvents True: Exit Sub
            K 
    = [{2,3,4,15}]
            
    Application.Index(Worksheets(1).UsedRange.Rows(1), , K)
            
    Application.Index(Worksheets(1).UsedRange.Rows(1), , [{16,16,17,17}])
        For 
    1 To Me.Index 1
            With Sheets
    (N).UsedRange
                    V 
    Application.Match(Target, .Columns(1), 0)
                If 
    IsNumeric(VThen
                    Cells
    (21).Value2 = .Parent.Name
                    Cells
    (31).Resize(, UBound(K)).Value2 H
                    R 
    4
                    Cells
    (R1).Resize(, UBound(K)).Value2 Application.Index(.Rows(V), , K)
                For 
    5 To 13 Step 2
                    
    If IsEmpty(.Cells(VC)) Then Exit For
                    
    1
                    Cells
    (R2).Resize(, 2).Value = .Cells(VC).Resize(, 2).Value
                Next
                    R 
    1
                    L
    (2) = .Cells(V16).Value2:  L(4) = .Cells(V17).Value2
                    Cells
    (R1).Resize(, UBound(L)).Value2 L
                End 
    If
            
    End With
        Next
            Application
    .EnableEvents True
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 01-19-2020 at 04:01 PM. Reason: oups …

  5. #5
    Registered User
    Join Date
    09-23-2019
    Location
    Ghana
    MS-Off Ver
    2016 32 bit and 64 bit
    Posts
    92

    Re: Fill a sheet with data from three different sheets, same workbook, in a very tricky wa

    The code worked like charm.

    What I need now is an explanation to what's going on there so that I modify it in the future.

    Most of the lines in your code are very strange to me. This means I have a long way to go. Lol.

  6. #6
    Registered User
    Join Date
    09-23-2019
    Location
    Ghana
    MS-Off Ver
    2016 32 bit and 64 bit
    Posts
    92

    Re: Hi ! Try this !

    This part of the code is what I don't understand, I want you to explain them to me. Thanks again.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    09-23-2019
    Location
    Ghana
    MS-Off Ver
    2016 32 bit and 64 bit
    Posts
    92

    Re: Fill a sheet with data from three different sheets, same workbook, in a very tricky wa

    Hi @Marc L

    I just found out that I am not getting the reply for the explanation because I am not asking the right questions.

    So, my actual dataset is from column BZ to CT.

    I am kind of working on some complex dataset ATM.

    Column BZ contains ID while CA takes names as, the one with the prototype I produced.

    So between the Target and owe, as on the prototype, I have three more columns between.

    But the rest stay the same.

    And instead of starting the data from row 2 as on the prototype, my actual data start from row 7.

    I know I am asking too much, but I have no other option.

    Can you please adjust the previous code to suit for me?

    Regards.

  8. #8
    Registered User
    Join Date
    09-23-2019
    Location
    Ghana
    MS-Off Ver
    2016 32 bit and 64 bit
    Posts
    92

    Re: Hi ! Try this !

    Quote Originally Posted by Marc L View Post

    With the item entry in OUT_PUT_DATA!B1 cell,

    a VBA beginner starter demonstration to paste to the (OUT_PUT_DATA) worksheet module :

    PHP Code: 
    Private Sub Worksheet_Change(ByVal Target As Range)
        
    Dim KHLN&, VR&, C%
            If 
    Target.Address <> "$B$1" Then Exit Sub
            Application
    .EnableEvents False
            Me
    .UsedRange.Offset(1).Clear
            
    If IsEmpty(TargetThen Application.EnableEvents True: Exit Sub
            K 
    = [{2,3,4,15}]
            
    Application.Index(Worksheets(1).UsedRange.Rows(1), , K)
            
    Application.Index(Worksheets(1).UsedRange.Rows(1), , [{16,16,17,17}])
        For 
    1 To Me.Index 1
            With Sheets
    (N).UsedRange
                    V 
    Application.Match(Target, .Columns(1), 0)
                If 
    IsNumeric(VThen
                    Cells
    (21).Value2 = .Parent.Name
                    Cells
    (31).Resize(, UBound(K)).Value2 H
                    R 
    4
                    Cells
    (R1).Resize(, UBound(K)).Value2 Application.Index(.Rows(V), , K)
                For 
    5 To 13 Step 2
                    
    If IsEmpty(.Cells(VC)) Then Exit For
                    
    1
                    Cells
    (R2).Resize(, 2).Value = .Cells(VC).Resize(, 2).Value
                Next
                    R 
    1
                    L
    (2) = .Cells(V16).Value2:  L(4) = .Cells(V17).Value2
                    Cells
    (R1).Resize(, UBound(L)).Value2 L
                End 
    If
            
    End With
        Next
            Application
    .EnableEvents True
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !
    The mention tag failed , so I have to use this method

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

    Arrow

    Quote Originally Posted by Kelly mort View Post
    Can you please adjust the previous code to suit for me?
    I won't waste time if you at least well follow the direction in my previous post
    and my demonstration still does not work on your side with your original attachment !

    As another point I work only on what I can load under Excel …

  10. #10
    Registered User
    Join Date
    09-23-2019
    Location
    Ghana
    MS-Off Ver
    2016 32 bit and 64 bit
    Posts
    92

    Re: Fill a sheet with data from three different sheets, same workbook, in a very tricky wa

    Quote Originally Posted by Marc L View Post
    I won't waste time if you at least well follow the direction in my previous post
    and my demonstration still does not work on your side with your original attachment !

    As another point I work only on what I can load under Excel …
    Okay thanks.

    But I will be glad if you can add some comments to the part of code I posted in post #6

    In that case I will be able to adjust it myself.

    Once again, I am very grateful

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

    Arrow

    Except Application.Match which is the MATCH worksheet function (so to see first in the Excel inner help if necessary)
    all statements are yet in the VBA inner help : just place the text cursor on a statement, hit F1 key then read …
    As that's the way I learned VBA.

    Another tip to understand what each codeline does : add first a breakpoint (F9 key) in the worksheet module
    at the beginning of the event, on sheet side change the B1 cell value,
    the execution stops on the breakpoint codeline then you can watch out what happens on sheet side
    or for any variable see its value within the VBE Locals window. Move to the next codeline via hitting F8 key (step-by-step mode) …

  12. #12
    Registered User
    Join Date
    09-23-2019
    Location
    Ghana
    MS-Off Ver
    2016 32 bit and 64 bit
    Posts
    92

    Re: Fill a sheet with data from three different sheets, same workbook, in a very tricky wa

    That was very helpful.

    I am so grateful for your time and patience.

    I was able to make it adjusted

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

    Thumbs up


    Well done ‼ And thanks for the rep !

  14. #14
    Registered User
    Join Date
    09-23-2019
    Location
    Ghana
    MS-Off Ver
    2016 32 bit and 64 bit
    Posts
    92

    Re: Fill a sheet with data from three different sheets, same workbook, in a very tricky wa

    Quote Originally Posted by Marc L View Post

    Well done ‼ And thanks for the rep !
    Please have a look at this link for me. Thanks
    https://www.excelforum.com/excel-pro...heets-vba.html

+ 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. [SOLVED] Transfer data from first sheet to various sheets in workbook
    By Lmao in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-15-2019, 08:47 AM
  2. Replies: 1
    Last Post: 11-01-2013, 07:32 PM
  3. Replies: 5
    Last Post: 10-28-2013, 01:26 PM
  4. [SOLVED] Insert copy of worksheet, remane and fill with data from another sheet in the workbook
    By Greaser2k in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-17-2012, 03:29 PM
  5. [SOLVED] VBA. One workbook, 9 sheets, how to transfer data from all sheets to one sheet?
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 05-08-2012, 01:28 PM
  6. Replies: 0
    Last Post: 08-11-2011, 01:23 AM
  7. [SOLVED] Copying data from workbook/sheets to another workbook/sheet
    By yukon_phil in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-26-2006, 02:35 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