Avatar of Ladydee
Ladydee
 asked on

multiple table in one worksheet into one master table using userform

Hi, i'm new in using excel macro and vba. In my workbook, there are large amount of uncluttered data in many table in one worksheet. I need help how to combine/merge/join multiple table in one worksheet into one master table into another worksheet using userform? i'm sorry if my explanation is confusing because I'm not so good in English. thank you for any help.
Microsoft ExcelVBAMicrosoft Office

Avatar of undefined
Last Comment
Shums Faruk

8/22/2022 - Mon
Shums Faruk

Hi,

I am not sure about the number of tables or DataBody of every table. I also hope you are referring to real table object not just Excel range.
Assuming your Data Sheet is Sheet1.
Please try below code, which will copy every table from Sheet1 to Master Sheet with the header leaving one row space in between to identify table contents.
Sub CopyTables()
Dim MstrSh As Worksheet, DataSh As Worksheet
Dim iTable_Count As Integer
Dim oListObject As ListObject

With Application
    .ScreenUpdating = False
    .DisplayStatusBar = True
    .StatusBar = "!!! Please Be Patient...Updating Records !!!"
    .EnableEvents = False
    .Calculation = xlManual
End With

'Delete Previous Master Worksheet & Insert a New Blank Worksheet With Same Name
On Error Resume Next
Application.DisplayAlerts = False
Worksheets("MasterSheet").Delete
Sheets.Add Before:=ActiveSheet
ActiveSheet.Name = "MasterSheet"
Application.DisplayAlerts = True
Set MstrSh = Worksheets("MasterSheet")
Set DataSh = Worksheets("Sheet1")

    iTable_Count = DataSh.ListObjects.Count
     
    If iTable_Count <= 0 Then
        MsgBox "No Tables found here!!!"
        Exit Sub
    End If
     
    For Each oListObject In DataSh.ListObjects
         'copy tables with headers...
        oListObject.Range.Copy Destination:=MstrSh.Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
    Next

With Application
    .ScreenUpdating = True
    .DisplayStatusBar = True
    .StatusBar = False
    .EnableEvents = True
    .Calculation = xlAutomatic
End With
End Sub

Open in new window

Ladydee

ASKER
use same question and want to added some attachment for this question.
Ladydee

ASKER
Hi, I'm sorry. here i attach sample for this question. Is there any code/script can be use to merge/join/combine multiple tables in same worksheet:
Capture.PNG
into one master table like this:
Capture1.PNG
one of my option is using userform:
Capture2.PNG
or any other suggestion? thank you for help.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER CERTIFIED SOLUTION
Shums Faruk

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.