Results 1 to 105 of 105

split Tables into multiple Tables for multiple sheets with different structure & arranging

Threaded View

abdo meghari split Tables into multiple... 02-23-2023, 02:30 AM
abdo meghari Re: split Tables into... 02-24-2023, 01:08 AM
abdo meghari Re: split Tables into... 02-25-2023, 05:13 AM
JohnTopley Re: split Tables into... 02-25-2023, 06:37 AM
abdo meghari Re: split Tables into... 02-25-2023, 05:06 PM
Marc L Re: split Tables into... 02-25-2023, 08:13 PM
abdo meghari Re: split Tables into... 02-26-2023, 12:43 AM
Marc L Re: split Tables into... 02-26-2023, 01:49 AM
abdo meghari Re: split Tables into... 02-26-2023, 02:44 AM
Marc L Re: split Tables into... 02-26-2023, 03:01 AM
JohnTopley Re: split Tables into... 02-26-2023, 03:46 AM
Marc L Re: split Tables into... 02-26-2023, 04:27 AM
abdo meghari Re: split Tables into... 02-26-2023, 05:04 AM
abdo meghari Re: split Tables into... 02-26-2023, 05:13 AM
JohnTopley Re: split Tables into... 02-26-2023, 05:38 AM
JohnTopley Re: split Tables into... 02-26-2023, 06:26 AM
Marc L Re: split Tables into... 02-26-2023, 10:52 AM
abdo meghari Re: split Tables into... 02-26-2023, 08:58 AM
Marc L Re: split Tables into... 02-27-2023, 10:56 AM
Marc L Erratum ... 02-28-2023, 03:44 AM
Marc L Re: split Tables into... 02-26-2023, 10:36 AM
abdo meghari Re: split Tables into... 02-26-2023, 04:01 PM
Marc L Re: split Tables into... 02-26-2023, 07:50 PM
abdo meghari Re: split Tables into... 02-27-2023, 04:22 AM
Marc L Re: split Tables into... 02-27-2023, 07:51 AM
JohnTopley Re: split Tables into... 02-27-2023, 09:33 AM
Marc L Re: split Tables into... 02-27-2023, 10:25 AM
abdo meghari Re: split Tables into... 02-27-2023, 03:35 PM
abdo meghari Re: split Tables into... 02-27-2023, 03:47 PM
Marc L Re: split Tables into... 02-27-2023, 06:34 PM
JohnTopley Re: split Tables into... 02-28-2023, 03:31 AM
abdo meghari Re: split Tables into... 02-28-2023, 05:04 AM
Marc L Re: split Tables into... 02-28-2023, 10:18 AM
abdo meghari Re: split Tables into... 02-28-2023, 03:23 PM
Marc L Re: split Tables into... 02-28-2023, 04:27 PM
abdo meghari Re: split Tables into... 03-01-2023, 05:01 AM
Marc L CRASH time so questions time ! 03-01-2023, 08:28 AM
abdo meghari Re: split Tables into... 03-01-2023, 08:50 AM
Marc L Re: split Tables into... 03-01-2023, 09:04 AM
Marc L Re: split Tables into... 03-01-2023, 10:54 AM
abdo meghari Re: split Tables into... 03-01-2023, 10:46 AM
abdo meghari Re: split Tables into... 03-01-2023, 11:38 AM
JohnTopley Re: split Tables into... 03-01-2023, 12:52 PM
Marc L Re: split Tables into... 03-01-2023, 03:39 PM
abdo meghari Re: split Tables into... 03-02-2023, 06:55 AM
Marc L Re: split Tables into... 03-02-2023, 08:28 AM
JohnTopley Re: split Tables into... 03-02-2023, 09:30 AM
abdo meghari Re: split Tables into... 03-02-2023, 06:57 AM
JohnTopley Re: split Tables into... 03-02-2023, 07:49 AM
Marc L Re: split Tables into... 03-02-2023, 08:21 AM
Marc L How it may work, or not ... 03-05-2023, 02:59 PM
abdo meghari Re: split Tables into... 03-02-2023, 03:23 PM
abdo meghari Re: split Tables into... 03-02-2023, 03:24 PM
Marc L Re: split Tables into... 03-02-2023, 08:59 PM
abdo meghari Re: split Tables into... 03-03-2023, 11:16 AM
abdo meghari Re: split Tables into... 03-03-2023, 11:42 AM
Marc L Question #2 ... 03-03-2023, 11:57 AM
abdo meghari Re: split Tables into... 03-03-2023, 12:34 PM
JohnTopley Re: split Tables into... 03-03-2023, 01:11 PM
Marc L Q2 and half ... 03-03-2023, 01:07 PM
Marc L Re: split Tables into... 03-03-2023, 01:16 PM
abdo meghari Re: split Tables into... 03-03-2023, 01:36 PM
abdo meghari Re: split Tables into... 03-03-2023, 01:39 PM
JohnTopley Re: split Tables into... 03-03-2023, 03:31 PM
Marc L Question #3 ... 03-03-2023, 07:35 PM
abdo meghari Re: split Tables into... 03-04-2023, 06:22 AM
Marc L Q3 and half ... 03-04-2023, 07:15 AM
Marc L Re: split Tables into... 03-07-2023, 11:27 AM
abdo meghari Re: split Tables into... 03-04-2023, 07:38 AM
Marc L Still Q3 & half ... 03-04-2023, 08:10 AM
abdo meghari Re: split Tables into... 03-04-2023, 11:56 AM
Marc L Q3 ... 03-04-2023, 12:08 PM
abdo meghari Re: split Tables into... 03-04-2023, 12:25 PM
Marc L Q3 solved ... 03-04-2023, 12:37 PM
abdo meghari Re: split Tables into... 03-04-2023, 12:42 PM
Marc L Question #4 : last but not... 03-04-2023, 12:44 PM
abdo meghari Re: split Tables into... 03-04-2023, 01:52 PM
Marc L Re: split Tables into... 03-04-2023, 04:52 PM
abdo meghari Re: split Tables into... 03-05-2023, 03:59 AM
Marc L Re: split Tables into... 03-05-2023, 07:54 AM
abdo meghari Re: split Tables into... 03-05-2023, 08:54 AM
Marc L How that works ... 03-05-2023, 10:11 AM
abdo meghari Re: split Tables into... 03-05-2023, 03:19 PM
Marc L Re: split Tables into... 03-05-2023, 03:29 PM
abdo meghari Re: split Tables into... 03-05-2023, 03:36 PM
Marc L Re: split Tables into... 03-05-2023, 03:40 PM
abdo meghari Re: split Tables into... 03-05-2023, 03:56 PM
Marc L Re: split Tables into... 03-05-2023, 06:38 PM
Marc L Re: split Tables into... 03-05-2023, 07:04 PM
Marc L Re: split Tables into... 03-05-2023, 07:17 PM
abdo meghari Re: split Tables into... 03-06-2023, 03:29 AM
Marc L New set of questions ... 03-06-2023, 06:15 AM
abdo meghari Re: split Tables into... 03-06-2023, 06:31 AM
Marc L Re: split Tables into... 03-06-2023, 08:07 AM
abdo meghari Re: split Tables into... 03-06-2023, 08:38 AM
Marc L Re: split Tables into... 03-06-2023, 09:12 AM
abdo meghari Re: split Tables into... 03-06-2023, 09:49 AM
Marc L Re: split Tables into... 03-06-2023, 11:18 AM
Marc L Re: split Tables into... 03-06-2023, 01:33 PM
abdo meghari Re: split Tables into... 03-06-2023, 02:23 PM
Marc L Re: split Tables into... 03-06-2023, 03:31 PM
abdo meghari Re: split Tables into... 03-07-2023, 03:16 AM
Marc L Try this ! 03-07-2023, 07:17 AM
abdo meghari Re: split Tables into... 03-07-2023, 10:15 AM
abdo meghari Re: split Tables into... 03-07-2023, 11:14 AM
  1. #11
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2507 Build 16.0.19029.20136) 64-bit
    Posts
    31,548

    Re: split Tables into multiple Tables for multiple sheets with different structure & arran

    Public OriginRng As Range, BrandRng As Range
    Sub Copy2Sheets()
    
        Dim src As Worksheet
        Dim trg As Worksheet
        Dim LastRow As Long, rcount As Long, srow As Long, lrow As Long
        Dim r As Long, c As Long
        
        Application.ScreenUpdating = False
        
        Set src = ThisWorkbook.Worksheets("tt")
        
        srow = 2
        
        With src
        
            .Activate
        
            LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
            Set srcRng = .Range("A1:A" & LastRow)
            shtname = .Cells(srow, "A")                          ' First sheet
            
            rcount = WorksheetFunction.CountIf(srcRng, shtname)
            lrow = srow + rcount - 1
            
            Set trg = ThisWorkbook.Worksheets(shtname)
            hdr = Array("Item", "Brand", "Origin", "Qty")
            
            For r = srow To lrow
                For c = 6 To 7
                If Cells(r, c) <> "" Then
                    Cells(r, 5) = Cells(r, 5) & " " & Cells(r, c)
                    Cells(r, c) = ""
                End If
                Next c
            Next r
            
            trg.Range("A1").Resize(1, 4) = hdr
            .Range("H" & srow & ":H" & lrow).Copy Destination:=trg.Range("A2")
            .Range("E" & srow & ":E" & lrow).Copy Destination:=trg.Range("B2")
            .Range("C" & srow & ":C" & lrow).Copy Destination:=trg.Range("C2")
            .Range("B" & srow & ":B" & lrow).Copy Destination:=trg.Range("D2")
            
            Set BrandRng = trg.Range("B2:B" & rcount + 1)
            Set OriginRng = trg.Range("C2:C" & rcount + 1)
            Call Get_Origin
            
            '************************************************************************
            hdr = Array("Sr", "Item Code", "Accepted Quantity")
            
            srow = lrow + 1
            shtname = .Cells(srow, "A")                         ' Second sheet
            srow = srow + 1
            rcount = WorksheetFunction.CountIf(srcRng, shtname) - 1
            lrow = srow + rcount - 1
            
            Set trg = ThisWorkbook.Worksheets(shtname)
             
             trg.Range("A1").Resize(1, 3) = hdr
            .Range("B" & srow & ":B" & lrow).Copy Destination:=trg.Range("A2")
            .Range("C" & srow & ":C" & lrow).Copy Destination:=trg.Range("B2")
            .Range("F" & srow & ":F" & lrow).Copy Destination:=trg.Range("C2")
            
            For i = 1 To rcount
                 trg.Range("B" & i + 1) = trg.Range("B" & i + 1) & " JAP"
                 trg.Range("C" & i + 1) = Replace(trg.Range("C" & i + 1), "Unit", "")
             Next i
            
            '************************************************************************
            hdr = Array("Sr", "Descriptione", "Production", "Qty")
            
            srow = lrow + 1
            shtname = .Cells(srow, "A")                            ' Third Sheet
            srow = srow + 1
            rcount = WorksheetFunction.CountIf(srcRng, shtname) - 1
            lrow = srow + rcount - 1
            
            Set trg = ThisWorkbook.Worksheets(shtname)
            
             trg.Range("A1").Resize(1, 4) = hdr
            .Range("E" & srow & ":E" & lrow).Copy Destination:=trg.Range("A2")
            .Range("D" & srow & ":D" & lrow).Copy Destination:=trg.Range("B2")
            .Range("B" & srow & ":B" & lrow).Copy Destination:=trg.Range("C2")
            .Range("C" & srow & ":C" & lrow).Copy Destination:=trg.Range("D2")
            
            Set BrandRng = trg.Range("B2:B" & rcount + 1)
            Set OriginRng = trg.Range("C2:C" & rcount + 1)
            Call Get_Origin
        
        End With
        
        Application.ScreenUpdating = True
    
        End Sub
    Sub Get_Origin()
    Dim a, n As Integer, i As Integer, c As Range, Origin As String
    
    a = Range("Short")
    n = 0
    
    For Each c In OriginRng
    
        n = n + 1
        For i = 1 To 7
         BrandRng(n) = Replace(BrandRng(n, 1), a(i, 1), "")
        Next i
        Origin = Application.WorksheetFunction.VLookup(c, Range("liss"), 2, False)
        BrandRng(n, 1).Value = Trim(BrandRng(n, 1).Value) & " " & Origin
        
    Next c
    
    End Sub
    Merges Cells and then clears

    I am sure Marc L will have some "smarter" code!
    Attached Files Attached Files
    Last edited by JohnTopley; 03-06-2023 at 07:20 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 03-04-2022, 08:30 AM
  2. Replies: 6
    Last Post: 04-22-2021, 03:41 PM
  3. Replies: 7
    Last Post: 11-28-2020, 06:55 PM
  4. Delete and add rows to multiple tables on multiple sheets using inputbox
    By Oliver_watkins in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-03-2020, 04:56 AM
  5. Copy Paste multiple tables from multiple sheets into Outlook email
    By DoodlesMama in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-25-2015, 12:21 PM
  6. Pivot Tables - need to do separate pivot tables for multiple sheets in same format
    By tconnell1965 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-18-2013, 07:04 AM
  7. [SOLVED] Split a long table to multiple tables
    By amasson in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-02-2013, 05:37 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