Question

create an excel macro to combine at least 16 tables in the same workbook with the...

create an excel macro to combine at least 16 tables in the same workbook with the same column headings to form one master table. There are other worksheets in the workbook, but not all of the sheets will be copied to the master.

Homework Answers

Answer #1

Pre req:1.Make sure your tabels are formatted correctly

2.all the tables column name shoud be same

3.Developer permissions to add macros/create macros

Steps:

Step1:Select the sheet which contains table :go to Data tab in Excel header section ->select any cell from table ->Select from table/range tab

Step2:This will bring up power query editor tab

Step:In the power query editor go to home page->select close & load dropdown->choose close & load To

Step4:Import Data window will be displayed->select Only create Connection radio button->click on ok

Step5:Queries and connection pane will be displayed for created table on the right hand side

Step6:Do this for all the tables and create connection

Step7:Select My Macro tab->click on PQ Connect All tables-> select yes from the popup->This will create all the connections in the workbook

Step8:Select Data tab->Queries and connections->combine queries->Append->In Append window select 3 or more tables radio button->Select the required tables for which you craeted connections ->click on ADD->Click okay

Step9:All the Tables will be combined together!!

Open ur excel with latest version click ALT+F11 then select developer tab vb editor->Macros->PQ connect all tables

and paste this code

Option Explicit

Sub Add_connection_All_Tables()

Dim wb As Workbook
Dim ws As Worksheet
Dim lo As ListObject
Dim sName As String
Dim sFormula As String
Dim wq As WorkbookQuery
Dim bExists As Boolean
Dim vbAnswer As VbMsgBoxResult
Dim vbDtaModel As VbMsgBoxResult
Dim i as Long
Dim dStart As Double
Dim dTrim AS Double

vbAnwer = MsgBox("Do you want to run the macro to create for all the tables selected"?)

If vbAnswer = vbYes Then

vbDataModel = MsgBox("Do you want to add the data to the Data model")

dStart = Timer
Set wb = ActiveWorkbook

For Each ws In ActiveWorkbook.Worksheets
For Each lo In ws.ListObjects

sName = lo.Name
sFormula= "Excel.CurrentWorkbook()({Name=""" & sName & """}}[Content]"

bExists = False
For Each wq In wb.Queries
if Instr(1, wq.Formula, sFormula) > 0 Then
bExists = True
End if
Next wq

If bExists  False Then

wb.Queries.Add Name:=aName,
Formula:="let" & Chr(13)& "" & Chr(10) & " Souce = Excel.CurrentWorkbook()

'Add Connection

vb.Connection.Add2 Name:="Query - " & aName,
Description:="Connection to the '" & sName
ConnectionString:"OLEDB;Provider=""
CommandText:"" & sName & "", _
lCmdtype:",_
CreateModelConnection:=False,_
Import Relationships:=False

Add to ADD model

if vbDatamodel = vbyes Then
vb.Connection Add2 Name:="Query - " & aName,
Description:="Connection to the '" & sName
ConnectionString:"OLEDB;Provider=""
CommandText:"" & sName & "", _
lCmdtype:",_
CreateModelConnection:=False,_
Import Relationships:=False

End If

i=i+1
End if

Next lo
Next ws

dTime = Timer = dstart

Msgbox i & " Connections have been craeted in "& Format(dTime,"0.0)

End If
End Sub 
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Once you have built the Excel tables, with all the changes in different tables, and answered...
Once you have built the Excel tables, with all the changes in different tables, and answered all the questions you have to send the work (Excel sheets and answered questions) to the professor using the Attach File function in Black Board to attach your document and send it to the professor. To use the Attach File enter the Course Content in Black Board. Select the Assignment Module 6, attach the file and submit. Solve the following problem and compute the...
1. Which step is first in viewing all the conditional rules you have applied to a...
1. Which step is first in viewing all the conditional rules you have applied to a Pivot Table? Select an answer: Open a new worksheet, then click any cell. Click any Totals or Subtotals cell within the Pivot Table. Click any cell on the worksheet outside of the Pivot Table. Click any cell on the within the Pivot Table. 2. Why would you use Data Bars with a Pivot Table? Select an answer: to horizontally display the relative magnitude of...
Using Microsoft Excel, create an investment cash-flow diagram that will have a present worth of zero...
Using Microsoft Excel, create an investment cash-flow diagram that will have a present worth of zero at MARR = 7%. The study period needs to be exactly 18 years and each year should have at least one unique cash-flow that is different from the cash-flows over the other years. Your answer should contain a table showing the cash-flows for each year and a graphical representation of the cash-flows (cash-flow diagram).
Using Microsoft Excel, create an investment cash-flow diagram that will have a present worth of zero...
Using Microsoft Excel, create an investment cash-flow diagram that will have a present worth of zero at MARR = 7%. The study period needs to be exactly 18 years and each year should have at least one unique cash-flow that is different from the cash-flows over the other years. Your answer should contain a table showing the cash-flows for each year and a graphical representation of the cash-flows (cash-flow diagram).
Assessment Module 9 – Marginal Analysis Please create a tab in your Excel Workbook and name...
Assessment Module 9 – Marginal Analysis Please create a tab in your Excel Workbook and name it “Module 9 Marginal Analysis.” You have same basic templates in your Resources workbook, but you may need to modify these to fit the individual business problem. I am evaluating your professional ability to do so, and to create professional models and reports, so take your time, think through a logical, clear, well-structured, well-formatted model. Remember, assumption tables (like T-accounts) are your friends! Be...
Create an original idea of a problem that you want to solve and the method you...
Create an original idea of a problem that you want to solve and the method you will go about to obtain the data to solve this problem. Use the ANOVA testing method to determine if the means are all equal or if at least one is not the same. As a reminder, here is ANOVA: H0:μ1=μ2=…=μmH0:μ1=μ2=…=μm H1:H1: At least one of the means is different from the rest. Please Use DataAnalysis in EXCEL. 35 5 5 10 13 9 40...
Use the following tables to answer Q5 and Q6. Tourist (tno, Name, phone, age,loc) Vehicle (Vno,...
Use the following tables to answer Q5 and Q6. Tourist (tno, Name, phone, age,loc) Vehicle (Vno, model, mileage, owner_name, owner_ph)) Rented (tno, Vno) 5. (i)Write an SQL query, to create the table vehicle with following constraints: Vno should begin with second letter ‘v’; Models are one among Thar, X3. Mileage should be above 18 and below 25. No two records can have same phone (ii) Write an SQL query to retrieve the name of the owner who does owns X3...
Exhibit 15-6 Below you are given a partial Excel output based on a sample of 16...
Exhibit 15-6 Below you are given a partial Excel output based on a sample of 16 observations. ANOVA df SS MS F Regression 4,853 2,426.5 Residual 485.3 Coefficients Standard Error Intercept 12.924 4.425 x1 -3.682 2.630 x2 45.216 12.560 1. Refer to Exhibit 15-6. The estimated regression equation is                 a.             y = β0 + β1x1 + β2x2 + ε                 b.             E(y) = β0 + β1x1 + β2x2                 c.             y hat = 12.924 - 3.682...
What is a Capital Asset?, Holding Period, Calculation of Gain or Loss, Net Capital Losses (LO...
What is a Capital Asset?, Holding Period, Calculation of Gain or Loss, Net Capital Losses (LO 8.1, 8.2, 8.3, 8.5) Charu Khanna received a Form 1099-B showing the following stock transactions and basis during 2016: Stock Date Purchased Date Sold Sales Price Cost Basis 4,000 shares Green Co. 06/04/05 08/05/16 $12,000 $3,000 500 shares Gold Co. 02/12/16 09/05/16 54,000 62,000 5,000 shares Blue Co. 02/04/06 10/08/16 18,000 22,000 100 shares Orange Co. 11/15/15 07/12/16 19,000 18,000 None of the stock...
In this assignment you will analyze the performance of actual company divisions. FASB ASC 280 (formerly...
In this assignment you will analyze the performance of actual company divisions. FASB ASC 280 (formerly SFAS 131) requires publicly traded companies to disclose segment information in the notes to the financial statements. You will use Excel to create visually appealing data tables and bar charts to analyze division performance, and then comment on the results.    Due Date: Tuesday, May 1, 2018.   Submit as an attachment in Blackboard in the Module 24 Assignment. SECTION I The link is to...