+ Reply to Thread
Results 1 to 14 of 14

Match & arrange data for multiple sheets based on another sheet

  1. #1
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    418

    Match & arrange data for multiple sheets based on another sheet

    Hello
    I want match all of the sheets for column B with sheet report for columns B:D then should arrange data in all of the sheets based on sheet report . with considering if I have new items in all sheets but are not existed in sheet REPORT , then should put in the last rows after arrange the items are matched . the result should be in the same range for each sheet but i put from column G to see how could be .
    important notice : I have about 1400 rows across sheets so I put just dummy data in simple file . and I will add new sheets with the same structure if I need it , also when update data in all of sheets should not be problem when run macro repeatedly .
    thanks
    Attached Files Attached Files

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,676

    Re: Match & arrange data for multiple sheets based on another sheet

    PHP Code: 
    Option Explicit
    Sub test
    ()
    Dim lr&, lc&, i&, j&, k&, t&, c&, ws As Worksheet
    Dim report
    (), rngarr()
    With Worksheets("REPORT")
        
    lr = .Cells(Rows.Count"B").End(xlUp).Row
        rng 
    = .Range("B3:D" lr).Value
        ReDim report
    (1 To lr1 To 1)
        For 
    1 To lr 2
            report
    (i1) = rng(i1) & " " rng(i2) & " " rng(i3)
        
    Next
    End With
    For Each ws In Sheets
        k 
    0
        
    If ws.Name <> "REPORT" Then
            lr 
    ws.Cells(Rows.Count"B").End(xlUp).Row
            lc 
    ws.Cells(1Columns.Count).End(xlToLeft).Column
            rng 
    ws.Range("A2"ws.Cells(lrlc)).Value
            ReDim arr
    (1 To lr 11 To lc)
            For 
    1 To UBound(report)
                For 
    1 To UBound(rng)
                    If 
    report(i1) = rng(j2Then
                        k 
    1
                        
    For 1 To lc
                            arr
    (kt) = rng(jt)
                        
    Next
                        arr
    (k1) = k
                    End 
    If
                
    Next
            Next
            
    For 1 To UBound(rng)
                
    0
                
    For 1 To UBound(arr)
                    If 
    rng(i2) = arr(j2Then c 1
                Next
                
    If 0 Then
                    k 
    1
                    
    For 1 To lc
                        arr
    (kt) = rng(it)
                    
    Next
                    arr
    (k1) = k
                End 
    If
            
    Next
            ws
    .Range("A2").Resize(UBound(arr), lc).Value arr
        End 
    If
    Next
    End Sub 
    Quang PT

  3. #3
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    418

    Re: Match & arrange data for multiple sheets based on another sheet

    magnificent !
    just I want clarifying from you about your code . does the code deal with huge data?
    I'm afraid to become slow when increase data . I don't want to come back to modifiying the code to deal with huge data .

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,676

    Re: Match & arrange data for multiple sheets based on another sheet

    try to duplicate data to 10,000 or even 100,000 rows, to see if it's acceptable.

  5. #5
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    418

    Re: Match & arrange data for multiple sheets based on another sheet

    ok I will do it and come back soon

  6. #6
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    418

    Re: Match & arrange data for multiple sheets based on another sheet

    what means this error subscript out of range in this line ?
    Please Login or Register  to view this content.
    I duplicate data to 28000 rows . by the way this error shows in the beginning I no know why and somtimes work without any problem .

  7. #7
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,676

    Re: Match & arrange data for multiple sheets based on another sheet

    Quote Originally Posted by KalilMe View Post
    I duplicate data to 28000 rows . by the way this error shows in the beginning I no know why and somtimes work without any problem .
    May be this:

    Dim lr&, lc&, i&, j&, k&, t&, c&

    Can you try to replace
    n&
    by
    n as long
    ?
    If it does not work, try to attach new file with 28.000 rows again.

  8. #8
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    418

    Re: Match & arrange data for multiple sheets based on another sheet

    Can you try to replace
    n&
    by
    n as long
    ?
    I don't see any variable n in your code
    can't upload file is too big . here is the link
    https://www.dropbox.com/scl/fi/b19bt...ofy03ozwwp5eu7

  9. #9
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,676

    Re: Match & arrange data for multiple sheets based on another sheet

    I mean change lr&,lc&,... to lr as long, lc as long,... anuthing with trailing "&"

  10. #10
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    418

    Re: Match & arrange data for multiple sheets based on another sheet

    thanks . still the error shows. did you upload my file and see the problem , please?

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,835

    Re: Match & arrange data for multiple sheets based on another sheet

    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    418

    Re: Match & arrange data for multiple sheets based on another sheet

    @jindon appreciated for your code , but I no know if you see post#8 .when have huge data the code seem slow gives running speed 35.12 .
    is it normal speed or you can make it better ?

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,835

    Re: Match & arrange data for multiple sheets based on another sheet

    If you are telling the truth, you should have many formulas running somewhere
    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    04-11-2021
    Location
    Tripoli
    MS-Off Ver
    Excel 2016 ,windows 10 64bit
    Posts
    418

    Re: Match & arrange data for multiple sheets based on another sheet

    @jindon thanks again
    this is much better

+ 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] auto fill columns for multiple sheets based on match column with another sheet
    By abdo meghari in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-01-2022, 01:52 PM
  2. [SOLVED] arrange & highlight data between two sheets based on column
    By Hasson in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-11-2021, 02:12 PM
  3. [SOLVED] Match between two sheets and bring missed elements based on column and arrange again
    By abdo meghari in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-24-2021, 10:46 AM
  4. [SOLVED] bring data from multiple sheets to one sheet based on name sheets
    By ABDELFATTA in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-01-2020, 05:27 PM
  5. [SOLVED] Arrange column data from multiple sheets based on two columns each sheet has.
    By Choochi in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 04-01-2020, 07:49 PM
  6. [SOLVED] Merge multiple sheets data into 1 sheet based on multiple criteria (List Based)
    By hecgroups in forum Excel Programming / VBA / Macros
    Replies: 43
    Last Post: 08-10-2018, 11:08 AM
  7. [SOLVED] Combine sheets into one excluding a specific sheet and arrange data accordingly
    By tantcu in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 02-16-2017, 12:58 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