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
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 WorksheetDim iTable_Count As IntegerDim oListObject As ListObjectWith Application .ScreenUpdating = False .DisplayStatusBar = True .StatusBar = "!!! Please Be Patient...Updating Records !!!" .EnableEvents = False .Calculation = xlManualEnd With'Delete Previous Master Worksheet & Insert a New Blank Worksheet With Same NameOn Error Resume NextApplication.DisplayAlerts = FalseWorksheets("MasterSheet").DeleteSheets.Add Before:=ActiveSheetActiveSheet.Name = "MasterSheet"Application.DisplayAlerts = TrueSet 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) NextWith Application .ScreenUpdating = True .DisplayStatusBar = True .StatusBar = False .EnableEvents = True .Calculation = xlAutomaticEnd WithEnd Sub
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:
into one master table like this:
one of my option is using userform:
or any other suggestion? thank you for help.
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.
Open in new window