Generating reports with excel

37

37 people found this article helpful

How to Create a Report in Excel

Using charts, graphs, and pivot tables makes it easy

Updated on September 25, 2022

What to Know

  • Create a report using charts: Select Insert > Recommended Charts, then choose the one you want to add to the report sheet.
  • Create a report with pivot tables: Select Insert > PivotTable. Select the data range you want to analyze in the Table/Range field.
  • Print: Go to File > Print, change the orientation to Landscape, scaling to Fit All Columns on One Page, and select Print Entire Workbook.

This article explains how to create a report in Microsoft Excel using key skills like creating basic charts and tables, creating pivot tables, and printing the report. The information in this article applies to Excel 2019, Excel 2016, Excel 2013, Excel 2010, and Excel for Mac.

Creating Basic Charts and Tables for an Excel Report

Creating reports usually means collecting information and presenting it all in a single sheet that serves as the report sheet for all of the information. These report sheets should be formatted in a way that’s easy to print as well.

One of the most common tools people use in Excel to create reports is the chart and table tools. To create a chart in an Excel report sheet:

  1. Select Insert from the menu, and in the charts group, select the type of chart you want to add to the report sheet.

  2. In the Chart Design menu, in the Data group, select Select Data.

  3. Select the sheet with the data and select all cells containing the data you want to chart (include headers).

  4. The chart will update in your report sheet with the data. The headers will be used to populate the labels in the two axis.

  5. Repeat the above steps to create new charts and graphs that appropriately represent the data you want to show in your report. When you need to create a new report, you can just paste the new data into the data sheets, and the charts and graphs update automatically.

    There are different ways to lay out a report using Excel. You can include graphs and charts on the same page as tabular (numeric) data, or you can create multiple sheets so visual reporting is on one sheet, tabular data is on another sheet, and so on.

Using PivotTables to Generate a Report From an Excel Spreadsheet

Pivot tables are another powerful tool for creating reports in Excel. Pivot tables help with digging more deeply into data.

  1. Select the sheet with the data you want to analyze. Select Insert > PivotTable.

  2. In the Create PivotTable dialogue, in the Table/Range field, select the range of data you want to analyze. In the Location field, select the first cell of the worksheet where you want the analysis to go. Select OK to finish.

  3. This will launch the pivot table creation process in the new sheet. In the PivotTable Fields area, the first field you select will be the reference field.

    In this example, this pivot table will show website traffic information by month. So, first, you’d select Month.

  4. Next, drag the data fields you want to show data for into the values area of the PivotTable fields pane. You’ll see the data imported from the source sheet into your pivot table.

  5. The pivot table collates all of the data for multiple items by adding them (by default). In this example, you can see which months had the most page views. If you want a different analysis, just select the drop-down arrow next to the item in the Values pane, then select Value Field Settings.

  6. In the Value Field Settings dialog box, change the calculation type to whichever you prefer.

  7. This will update the data in the pivot table accordingly. Using this approach, you can perform any analysis you like on source data, and create pivot charts that display the information in your report in the way you need.

How to Print Your Excel Report

You can generate a printed report from all the sheets you created, but first you need to add page headers.

  1. Select Insert > Text > Header & Footer.

  2. Type the title for the report page, then format it to use larger than normal text. Repeat this process for each report sheet you plan to print.

  3. Next, hide the sheets you don’t want included in the report. To do this, right-click the sheet tab and select Hide.

  4. To print your report, select File > Print. Change orientation to Landscape, and scaling to Fit All Columns on One Page.

  5. Select Print Entire Workbook. Now when you print your report, only the report sheets you created will print as individual pages.

    You can either print your report out on paper, or print it as a PDF and send it out as an email attachment.

FAQ

  • How do I create an expense report in Excel?

    Open an Excel spreadsheet, turn off gridlines, and enter your basic expense report information, such as a title, time period, and employee name. Add data columns for Date and Description, and then add columns for expense specifics, such as Hotel, Meals, and Phone. Enter your information and create an Excel table.

  • How do I create a scenario summary report in Excel?

    To use Excel’s scenario manager function, select the cells with the information you’re exploring, and then go to the ribbon and select Data. Select What-If Analysis > Scenario Manager. In the Scenario Manager dialog box, select Add. Name the scenario and change your data to see various outcomes.

  • How do I export a Salesforce report to Excel?

    In Salesforce, go to Reports and find the report you want to export. Select Export and choose an export view (Formatted Report or Details Only). Formatted Report will export in .xlsx format, while Details Only gives you other choices. Select Export when ready.

Thanks for letting us know!

Get the Latest Tech News Delivered Every Day

Subscribe

Содержание

  1. Create status and trend reports from a work item query
  2. Prerequisites
  3. Create an Excel report from a flat-list query
  4. Create a query-based report by using Excel
  5. Q: Can I export a query to Excel?
  6. Q: Which fields can’t I use to generate a report?
  7. Q: Can I create reports if I’m working in Azure DevOps?
  8. Q: How do I refresh the report to show the most recent data?
  9. How to Create a Report in Excel
  10. In This Article
  11. What to Know
  12. Creating Basic Charts and Tables for an Excel Report
  13. Using PivotTables to Generate a Report From an Excel Spreadsheet
  14. How to Print Your Excel Report

Create status and trend reports from a work item query

TFS 2017 | TFS 2015 | TFS 2013

One of the quickest ways to generate a custom work tracking report is to use Excel and start with a flat list query. You can generate both status and trend charts. Also, once you’ve built a report, you can manipulate the data further by adding or filtering fields using the PivotTable.

This feature is supported for the following versions and configurations:

  • Azure DevOps Server 2020 and earlier versions configured with SQL Server Analysis Services.
  • For Azure DevOps Server 2019 and Azure DevOps Server 2020, supports projects that are defined on project collections configured with the On-premises XML process model. If your collection is configured to support the Inheritance process model, you can use Analytics views to filter work items and generate Power BI reports. To learn more, see What are Analytics views? To learn more about process models, see Customize your work tracking experience.

If you want to export work items to Excel, see Bulk add or modify work items with Excel. To get the latest version of the Azure DevOps add-in for Office, install Azure DevOps Office® Integration 2019.

Here’s an example of a status report generated from a flat-list query.

Prerequisites

You can generate these reports only when you work with an on-premises Azure DevOps Server that has been configured with reporting services.

Your deployment needs to be integrated with reporting services. If your on-premises application-tier server hasn’t been configured to support reporting services, you can add that functionality by following the steps provided here: Add reports to a team project.

You must be a member of the TfsWarehouseDataReader security roles. To get added, see Grant permissions to view or create reports in Azure DevOps Server.

A version of Excel that is compatible with your version of Azure DevOps, such as Office 2010 or later version. For a complete list of supported versions, see Azure DevOps client compatibility, Microsoft Office integration. If you don’t have Excel, install it now.

A version of Visual Studio that supports the Team Explorer plugin, such as Visual Studio or Visual Studio Community. You can install Visual Studio from this download site. Team Explorer is free and requires a Windows OS.

To work from Microsoft Excel and use the Team menu, you’ll need to install Azure DevOps Office® Integration 2019.

Create an Excel report from a flat-list query

Use this procedure when you work from the Team Explorer plug-in for Visual Studio.

Create or open a flat-list query that contains the work items that you want to include in the report.

To view queries in Visual Studio 2019 and later versions, you must choose the Tools option Legacy experience (compatibility mode) as described in Set the Work Items experience in Visual Studio 2019.

Choose the fields you want to base reports on and include them in the filter criteria or as a column option. For non-reportable fields, see Q: Which fields are non-reportable?

Create a report in Excel From the query results view. The option to Create Report in Microsoft Excel only appears if all prerequisites are met.

Select the check boxes of the reports that you want to generate.

Wait until Excel finishes generating the reports. This step might take several minutes, depending on the number of reports and quantity of data.

Each worksheet displays a report. The first worksheet provides hyperlinks to each report. Pie charts display status reports and area graphs display trend charts.

To view a report, choose a tab, for example, choose the State tab to view the distribution of work items by State.

You can change the chart type and filters. For more information, see Use PivotTables and other business intelligence tools to analyze your data.

Create a query-based report by using Excel

Use this procedure when you work from the web portal or the Team Explorer plug-in for Visual Studio.

Open an Office Excel workbook and choose New Report.

The option New Report appears even if all prerequisites aren’t met. Choosing it may cause Excel to stop responding or display the following error message:

If you don’t see the Team menu, you’ll need to install you’ll need to install the Azure DevOps Office® Integration 2019. See Requirements listed earlier in this article.

Connect to the project and choose the query.

If the server you need isn’t listed, add it now.

Choose the reports to generate (steps 3 and 4 from the previous procedure).

Q: Can I export a query to Excel?

A: If you want to export a query to Excel, you can do that from Excel or Visual Studio/Team Explorer. Or, to export a query directly from the web portal Queries page, install the Azure DevOps Open in Excel Marketplace extension. This extension adds an Open in Excel link to the toolbar of the query results page.

Q: Which fields can’t I use to generate a report?

A: Even though you can include non-reportable fields in your query field criteria or as a column option, they won’t be used to generate a report.

Description, History, and other HTML data-type fields. These fields won’t be added to the PivotTable or used to generate a report. Excel does not support generating reports on these fields.

Fields with filter criteria that specify the Contains, Contains Words, Does Not Contain, or Does Not Contain Words operators will not be added to the PivotTable. Excel does not support these operators. To learn more about these operators, see Query fields, operators, and macros.

Q: Can I create reports if I’m working in Azure DevOps?

A: You can’t create Excel reports; however, you can create query-based charts, generate Power BI reports using an Analytics views, or use the Analytics Service.

Q: How do I refresh the report to show the most recent data?

A: At any time, you can choose Refresh on the Data tab within Excel to update the data for the PivotTables in your workbook. To learn more, see Refresh PivotTable data.

Источник

How to Create a Report in Excel

Using charts, graphs, and pivot tables makes it easy

In This Article

Jump to a Section

What to Know

  • Create a report using charts: Select Insert >Recommended Charts, then choose the one you want to add to the report sheet.
  • Create a report with pivot tables: Select Insert >PivotTable. Select the data range you want to analyze in the Table/Range field.
  • Print: Go to File >Print, change the orientation to Landscape, scaling to Fit All Columns on One Page, and select Print Entire Workbook.

This article explains how to create a report in Microsoft Excel using key skills like creating basic charts and tables, creating pivot tables, and printing the report. The information in this article applies to Excel 2019, Excel 2016, Excel 2013, Excel 2010, and Excel for Mac.

Creating Basic Charts and Tables for an Excel Report

Creating reports usually means collecting information and presenting it all in a single sheet that serves as the report sheet for all of the information. These report sheets should be formatted in a way that’s easy to print as well.

One of the most common tools people use in Excel to create reports is the chart and table tools. To create a chart in an Excel report sheet:

Select Insert from the menu, and in the charts group, select the type of chart you want to add to the report sheet.

In the Chart Design menu, in the Data group, select Select Data.

Select the sheet with the data and select all cells containing the data you want to chart (include headers).

The chart will update in your report sheet with the data. The headers will be used to populate the labels in the two axis.

Repeat the above steps to create new charts and graphs that appropriately represent the data you want to show in your report. When you need to create a new report, you can just paste the new data into the data sheets, and the charts and graphs update automatically.

There are different ways to lay out a report using Excel. You can include graphs and charts on the same page as tabular (numeric) data, or you can create multiple sheets so visual reporting is on one sheet, tabular data is on another sheet, and so on.

Using PivotTables to Generate a Report From an Excel Spreadsheet

Pivot tables are another powerful tool for creating reports in Excel. Pivot tables help with digging more deeply into data.

Select the sheet with the data you want to analyze. Select Insert > PivotTable.

In the Create PivotTable dialogue, in the Table/Range field, select the range of data you want to analyze. In the Location field, select the first cell of the worksheet where you want the analysis to go. Select OK to finish.

This will launch the pivot table creation process in the new sheet. In the PivotTable Fields area, the first field you select will be the reference field.

In this example, this pivot table will show website traffic information by month. So, first, you’d select Month.

Next, drag the data fields you want to show data for into the values area of the PivotTable fields pane. You’ll see the data imported from the source sheet into your pivot table.

The pivot table collates all of the data for multiple items by adding them (by default). In this example, you can see which months had the most page views. If you want a different analysis, just select the drop-down arrow next to the item in the Values pane, then select Value Field Settings.

In the Value Field Settings dialog box, change the calculation type to whichever you prefer.

This will update the data in the pivot table accordingly. Using this approach, you can perform any analysis you like on source data, and create pivot charts that display the information in your report in the way you need.

How to Print Your Excel Report

You can generate a printed report from all the sheets you created, but first you need to add page headers.

Select Insert > Text > Header & Footer.

Type the title for the report page, then format it to use larger than normal text. Repeat this process for each report sheet you plan to print.

Next, hide the sheets you don’t want included in the report. To do this, right-click the sheet tab and select Hide.

To print your report, select File > Print. Change orientation to Landscape, and scaling to Fit All Columns on One Page.

Select Print Entire Workbook. Now when you print your report, only the report sheets you created will print as individual pages.

You can either print your report out on paper, or print it as a PDF and send it out as an email attachment.

Open an Excel spreadsheet, turn off gridlines, and enter your basic expense report information, such as a title, time period, and employee name. Add data columns for Date and Description, and then add columns for expense specifics, such as Hotel, Meals, and Phone. Enter your information and create an Excel table.

To use Excel’s scenario manager function, select the cells with the information you’re exploring, and then go to the ribbon and select Data. Select What-If Analysis > Scenario Manager. In the Scenario Manager dialog box, select Add. Name the scenario and change your data to see various outcomes.

In Salesforce, go to Reports and find the report you want to export. Select Export and choose an export view (Formatted Report or Details Only). Formatted Report will export in .xlsx format, while Details Only gives you other choices. Select Export when ready.

Источник


Download Article


Download Article

This wikiHow teaches you how to automate the reporting of data in Microsoft Excel. For external data, this wikiHow will teach you how to query and create reports from any external data source (MySQL, Postgres, Oracle, etc) from within your worksheet using Excel plugins that link your worksheet to external data sources.

For data already stored in an Excel worksheet, we will use macros to build reports and export them in a variety of file types with the press of one key. Luckily, Excel comes with a built-in step recorder which means you will not have to code the macros yourself.

  1. Image titled Automate Reports in Excel Step 1

    1

    If the data you need to report on is already stored, updated, and maintained in Excel, you can automate reporting workflows using Macros. Macros are a built in function that allow you to automate complex and repetitive tasks.

  2. Image titled Automate Reports in Excel Step 2

    2

    Open Excel. Double-click (or click if you’re on a Mac) the Excel app icon, which resembles a white «X» on a green background, then click Blank Workbook on the templates page.

    • On a Mac, you may have to click File and then click New Blank Workbook in the resulting drop-down menu.
    • If you already have an Excel report that you want to automate, you’ll instead double-click the report’s file to open it in Excel.

    Advertisement

  3. Image titled Automate Reports in Excel Step 3

    3

    Enter your spreadsheet’s data if necessary. If you haven’t added the column labels and numbers for which you want to automate results, do so before proceeding.

  4. Image titled Automate Reports in Excel Step 4

    4

    Enable the Developer tab. By default, the Developer tab doesn’t show up at the top of the Excel window. You can enable it by doing the following depending on your operating system:

    • Windows — Click File, click Options, click Customize Ribbon on the left side of the window, check the «Developer» box in the lower-right side of the window (you may first have to scroll down), and click OK.[1]
    • Mac — Click Excel, click Preferences…, click Ribbon & Toolbar, check the «Developer» box in the «Main Tabs» list, and click Save.[2]
  5. Image titled Automate Reports in Excel Step 5

    5

    Click Developer. This tab should now be at the top of the Excel window. Doing so brings up a toolbar at the top of the Excel window.

  6. Image titled Automate Reports in Excel Step 6

    6

    Click Record Macro. It’s in the toolbar. A pop-up window will appear.

  7. Image titled Automate Reports in Excel Step 7

    7

    Enter a name for the macro. In the «Macro name» text box, type in the name for your macro. This will help you identify the macro later.

    • For example, if you’re creating a macro that will make a chart out of your available data, you might name it «Chart1» or similar.
  8. Image titled Automate Reports in Excel Step 8

    8

    Create a shortcut key combination for the macro. Press the Shift key along with another key (e.g., the T key) to create the keyboard shortcut. This is what you’ll use to run your macro later.

    • On a Mac, the shortcut key combination will end up being Option+ Command and your key (e.g., Option+ Command+T).
  9. Image titled Automate Reports in Excel Step 9

    9

    Store the macro in the current Excel document. Click the «Store macro in» drop-down box, then click This Workbook to ensure that the macro will be available for anyone who opens the workbook.

    • You’ll have to save the Excel file in a special format for the macro to be saved.
  10. Image titled Automate Reports in Excel Step 10

    10

    Click OK. It’s at the bottom of the window. Doing so will save your macro settings and place you in record mode. Any steps you take from now until you stop the recording will be recorded.

  11. Image titled Automate Reports in Excel Step 11

    11

    Perform the steps that you want to automate. Excel will track every click, keystroke, and formatting option you enter and add them to the macro’s list.

    • For example, to select data and create a chart out of it, you would highlight your data, click Insert at the top of the Excel window, click a chart type, click the chart format that you want to use, and edit the chart as needed.
    • If you wanted to use the macro to add values from cells A1 through A12, you would click an empty cell, type in =SUM(A1:A12), and press Enter.
  12. Image titled Automate Reports in Excel Step 12

    12

    Click Stop Recording. It’s in the Developer tab’s toolbar. This will stop your recording and save any steps you took during the recording as an individual macro.

  13. Image titled Automate Reports in Excel Step 13

    13

    Save your Excel sheet as a macro-enabled file. Click File, click Save As, and change the file format to xlsm instead of xls. You can then enter a file name, select a file location, and click Save.

    • If you don’t do this, the macro won’t be saved as part of the spreadsheet, meaning that other people on different computers won’t be able to use your macro if you send the workbook to them.
  14. Image titled Automate Reports in Excel Step 14

    14

    Run your macro. Press the key combination which you created as part of the macro to do so. You should see your spreadsheet automate according to your macro’s steps.

    • You can also run a macro by clicking Macros in the Developer tab, selecting your macro’s name, and clicking Run.
  15. Advertisement

  1. Image titled Automate Reports in Excel Step 15

    1

    Download Kloudio’s Excel plugin from Microsoft AppSource. This will allow you to create a persistent connection between an external database or data source and your workbook. This plugin also works with Google Sheets.

  2. Image titled Automate Reports in Excel Step 16

    2

    Create a connection between your worksheet and your external data source by clicking the + button on the Kloudio portal. Type in the details of your database (database type, credentials) and select any security/encryption options if working with confidential or company data.

  3. Image titled Automate Reports in Excel Step 17

    3

    Once you’ve created a connection between your worksheet and your database, you will be able to query and build reports from external data without leaving Excel. Create your custom reports from the Kloudio portal and then select them from the drop-down menu in Excel. You can then apply any additional filters and choose the frequency that the report will refresh (so you can have your sales spreadsheet update automatically every week, day, or even hour.)

  4. Image titled Automate Reports in Excel Step 18

    4

    In addition, you can also input data into your connected worksheet and have the data update your external data source. Create an upload template from the Kloudio portal and you will be able to manually or automatically upload changes in your spreadsheet to your external data source.

  5. Advertisement

Ask a Question

200 characters left

Include your email address to get a message when this question is answered.

Submit

Advertisement

Video

  • Only download Excel plugins from Microsoft AppSource, unless you trust the third party provider.

  • Macros can be used for anything from simple tasks (e.g., adding values or creating a chart) to complex ones (e.g., calculating your cell’s values, creating a chart from the results, labeling the chart, and printing the result).

  • When opening a spreadsheet with your macro included, you may have to click Enable Content in a yellow banner at the top of the window before you can use the macro.

Thanks for submitting a tip for review!

Advertisement

  • Macros can be used maliciously (e.g., to delete files on your computer). Don’t run macros from untrustworthy sources.

  • Macros will implement literally every step you make while recording. Make sure that you don’t accidentally enter the incorrect value, open a program you don’t want to use, or delete a file.

Advertisement

About This Article

Article SummaryX

1. Enable the Developer tab.
2. Click the Developer tab.
3. Click Record Macro.
4. Create a shortcut key.
5. Store the content in the current workbook.
6. Click OK.
7. Perform the steps you want to automate.
8. Click Stop Recording.
9. Use the shortcut key to run the same steps.

Did this summary help you?

Thanks to all authors for creating a page that has been read 543,765 times.

Is this article up to date?

Many small-scale businesses do not use database management systems to generate reports. Most of them stick to spreadsheet packages. Unfortunately Spreadsheet softwares are not equipped with  advanced query and report generating features. However, some Excel users struggle with Reports that they update, save and print manually. It is a very tedious job, but VBA can make it better. I have created a spreadsheet application you may used to fill a template/report with different “Records“, save each in a separate workbook, and print automatically.

Borrowing a few terms from Database Packages, first, we need to organize the data that goes into the report in a neat ‘Table’. A database entry, also called a ‘Record‘, has information under various headers called ‘Fields‘. A record needs to be uniquely Identifiable with a ‘Key‘. In this application, the ‘Table‘ is stored in the ‘Data‘ Sheet. The ‘Field‘ names are stored in a Row named ‘Field Names‘. Each Row corresponds to a ‘Record‘ and the ‘Keys‘ are generated automatically when the user clicks the ‘Set-up‘ button.

The next thing we need to do is to set-up the Report which needs to be filled with data from the ‘Table‘.  This is done in the ‘Template‘ sheet. The cells in this sheet need to be linked to ‘Fields‘ corresponding to the required ‘Record‘. This is accomplished by using an intermediate ‘Mapping‘ Sheet. In this sheet, the user can extract all the fields of a particular record, by specifying its ‘Key‘. Clicking the ‘Export‘ button loops through all the ‘Keys‘, updates the ‘Mapping‘ sheet and exports the ‘Template’ into individual workbooks.

Excel Report Generator

I urge you to download the application from the section below, and give it a whirl.


How to use this application?

Step 1 : Import your records into the ‘Data’ sheet.

  • Fill in the Field Names/Column Headers
  • Copy paste records. Preferably as Values.
  • Click the ‘Set Up’ Button

Step 2 : Setup your Template

  • Paste your Template into the ‘Template’ Sheet. Copy pasting all (Ctrl+V).
  • Link the “Fields” to the cells in the ‘Mapping’ spreadsheet
  • Print Page Setup the sheet. Also set the Default Printer to the available one.

Step 3 : Set Preferences in the ‘Mapping’ sheet

  • Which records you want to save?  – Set the Start and Stop Record Numbers
  • Do you want to print each export when they are created? – Yes/No
  • Set up a file name tag that is unique for each record. Example: =”Record – “&TEXT(RecordNumber,”000”). Feel free to use the mapping ranges to add in any unique Identification Numbers. Make sure it does not contain any special characters. Set up a similar name for the sheet name.
  • Choose if you’d like to protect the sheets, workbooks and File; and specify the respective password. Remember Protecting the sheet does not allow users to make changes to the sheet; protecting the workbook does not allow the user to change the structure of the workbook. And protecting the file does not allow the user to open the workbook without keying in the correct password.
  • While saving a workbook, Excel usually prompts the user for confirmation if a workbook with the same name exists already. Setting the ‘Replace Without Prompt’ option to ‘Yes’ will replace existing files without the prompt.
  • Click the browse button to specify where the output files should be saved. If left blank, the files would be saved along with this workbook.
  • Hit the ‘Reset’ button to bring back the default options.

Step 4 : Hit the Export Button


How to incorporate these into your other projects?

I understand that you May not be interested in using this Spreadsheet application in its entirety. However, you may interested in incorporate the Loop-and-Export functionality into your existing applications. Therefore, I have two versatile Macros that you can use in your applications.

Macro 1 : Macro that exports a Spreadsheet into a Workbook.

'====================================================================================
'A macro that exports a sheet to a workbook. It has a few optional arguments that
'make it versatile.
'Arguments:
'WhichSheet - Worksheet Object. The sheet that needs to be exported. If not specified,
'               The active sheet will be exported.
'ToWhichBook - Workbook Object. The sheet specifed earlier will be copied to this
'               workbook. If not specified, a new workbook will be created.
'               If you'd like a reference to the workbook that was created, pass an
'               empty workbook object as argument to this sub. Will come on handy while
'               exporting multiple WorkSheets to a new workbook. And it will also help
'               in saving the created workbook later.
'SheetName - String Variable. An optional arguemnt that will be used to set the name of
'               the newly created sheet. If not specified, it will be set to the name
'               of 'WhichSheet'
'OnlyValues - Boolean Variable. An optional argument that can be set to True to convert
'               all the references to values. It is set to True by defauly. Set it to
'               False if you'd like to retain the formulas.
'ProtectSheet - Boolean Variable. Set to true if you'd like to protect the newly created
'               WorkSheet.
'SheetPassword - String Variable. Password to protect the sheet with.

'Author : Ejaz Ahmed - ejaz.ahmed.1989@gmail.com
'Date: 30 January 2013
'Website : http://strugglingtoexcel.wordpress.com/
'====================================================================================
Sub ExportSheetToBook(Optional ByRef WhichSheet As Worksheet, _
                        Optional ByRef ToWhichBook As Workbook, _
                        Optional ByVal SheetName As String = "", _
                        Optional ByVal OnlyValues As Boolean = True, _
                        Optional ByVal ProtectSheet As Boolean = False, _
                        Optional ByVal SheetPassword As String = "")

'Declare Sub Level Objects/Variables

'A newly created workbook contains a number of sheets. All of them cannot
'be deleted, one has to remain. It has to be deleted only after the intended
'sheet has been imported.
Dim shtDeleteFinal As Worksheet
'A WorkSheet object to use in the for loops
Dim shtEach As Worksheet
'A WorkSheet object to hold the sheet that was imported
Dim shtCopied As Worksheet
'A long variable to use in for loops
Dim lngCount As Long
'A Boolean variable to hold the DisplayAllert status temporarily
Dim booStatusAlerts As Boolean

'Set the boolean variable to the current DisplayAlerts status
booStatusAlerts = Application.DisplayAlerts

'Set WhichSheet to ActiveSheet if a sheet was not passed to the sub
If WhichSheet Is Nothing Then
    Set WhichSheet = Application.ActiveSheet
End If

'Create a new workbook if no workbook was passed to the sub. A new
'workbook will be created even if an uninitialized workbook object
'was passed to the sub.
If ToWhichBook Is Nothing Then
    'Create a new Workbook
    Set ToWhichBook = Application.Workbooks.Add
    'Set the First Sheet to a WorkSheet object, for deleting it later
    Set shtDeleteFinal = ToWhichBook.Sheets(1)
        'Supress Alerts, for excel prompts for a confirmation when the
        'user deletes a WorkSheet
        Application.DisplayAlerts = False
        'Delete all the WorkSheets except the first one
        For Each shtEach In ToWhichBook.Sheets
            If Not shtEach Is shtDeleteFinal Then
                shtEach.Delete
            End If
        Next shtEach
End If

'Copy the WorkSheet to the intended workbook before the first WorkSheet
WhichSheet.Copy Before:=ToWhichBook.Worksheets(ToWhichBook.Sheets(1).Name)
'Now the newly copied WorkSheet will be the first sheet in the workbook
'Initialize a WorkSheet object to remember the sheet
Set shtCopied = ToWhichBook.Worksheets(ToWhichBook.Sheets(1).Name)

'If the user wants only Values, convert formula to values.
If OnlyValues Then
    Call modSupport.ChangeValueToFormula(shtCopied.Cells.SpecialCells(xlCellTypeFormulas))
End If

'Delete the One sheet that was not deleted earlier
If Not shtDeleteFinal Is Nothing Then
    shtDeleteFinal.Delete
    Set shtDeleteFinal = Nothing
End If

'Restore the DisplayAlerts status
Application.DisplayAlerts = booStatusAlerts

'If the user specified a WorkSheet name, then rename it
If Not SheetName = vbNullString Then
    shtCopied.Name = SheetName
End If

'If the user wants to protect the sheet, Protect it with the
'specified password.
If ProtectSheet Then
    shtCopied.Protect Password:=SheetPassword
End If

End Sub

Macro 2 : Loops through a specified range of ‘Keys’ and Exports the ‘Templates’.

'====================================================================================
'A macro that loops through a specified range of 'Key' and exports the 'Templates'.
'It contains a lot of optional arguments that may be used the customize the export
'Process
'Arguments:
'LngStart - Long Variable. Starting 'Key' number
'LngEnd - Long Variable. Ending 'Key' number
'rngUpdate - Range Object - The cell that needs to be updated with the current
'               'Key' number that is being exported. The Index functions used to
'               lookup the records depend on this cell.
'shtTemplate = WorkSheet object. The Template sheet that needs to be exported
'strOutputFolder - String Variable - Folder path  where the files need to be
'                   saved. This workbook's path will be used if left blank.
'booProtectSheet, booProtectBook, booProtectFile - Boolean Variables. The
'                   respective objects will be protected with corresponding
'                   passwords specified in strPwdSheet, strPwdBoook, strPwdFile
'                   respectively.
'strPwdSheet, strPwdBoook, strPwdFile - String Variables. Passwords to protect the
'                   sheet, book and file respectively.
'rngSheetName - Range Object - The user has the option to set up a cell that will
'                   create a unique name for the WorkSheet that is exported. If
'                   this arguement is not specified a default name is generated.
'rngFileName - Range Object - The user has the option to set up a cell that will
'                   create a unique name for the WorkBook that is created. If this
'                   arguement is not specified a default name is generated.
'booSaveFile - Boolean Variable. User can choose if each export is saved as an
'               individual file.
'booCloseFile - Boolean Variable. The user can choose if the workbook should be
'               closed after Saving/Printing.
'booPrint - Boolean Variable. The user can choose if the sxported sheet should be
'               printed using the default printer.
'booReplace - Boolean Variable. The user can choose to supress the "Do you want to
'               replace the file? prompt.
'booUpdateStatus - Boolean Variable. The user can choose if the status bar should
'               show a quick update on which record is being processed.
'booPromptComplete - Boolean Variable. The user can choose to dispaly an alert when
'               the loop is done
'
'Author : Ejaz Ahmed - ejaz.ahmed.1989@gmail.com
'Date: 30 January 2013
'Website : http://strugglingtoexcel.wordpress.com/
'====================================================================================
Sub ExportRun(ByVal LngStart As Long, _
                ByVal LngEnd As Long, _
                ByRef rngUpdate As Range, _
                ByRef shtTemplate As Worksheet, _
                Optional ByVal strOutputFolder As String = vbNullString, _
                Optional ByVal booProtectSheet As Boolean = False, _
                Optional ByVal strPwdSheet As String = vbNullString, _
                Optional ByVal booProtectBook As Boolean = False, _
                Optional ByVal strPwdBook As String = vbNullString, _
                Optional ByVal booProtectFile As Boolean = False, _
                Optional ByVal strPwdFile As String = vbNullString, _
                Optional ByRef rngSheetName As Range, _
                Optional ByRef rngFileName As Range, _
                Optional ByVal booSaveFile As Boolean = True, _
                Optional ByVal booCloseFile As Boolean = True, _
                Optional ByVal booPrint As Boolean = False, _
                Optional ByVal booReplace As Boolean = True, _
                Optional ByVal booUpdateStatus As Boolean = False, _
                Optional ByVal booPromptComplete As Boolean = True)

'An empty WorkBook object to retain a reference to the new
'workbook that would be created by the 'ExportSheetToBook' macro
Dim wkbBook As Workbook
'A Long variable used in the For Loops
Dim lngCount As Long
'String Variables to hold the Sheet, Book and File names.
Dim strSheetName As String
Dim strBookName As String
Dim strBookPath As String

'If the user did not specify a part, use ThisWorkBook's path
If strOutputFolder = vbNullString Then
    strOutputFolder = shtTemplate.Parent.Path & ""
End If

'If the user chooses to Replace Files without Prompt
'Suppress the Alerts
If booReplace Then
    Dim booStatusAlerts As Boolean
    booStatusAlerts = Application.DisplayAlerts
    Application.DisplayAlerts = False
End If

'Start the Loop
For lngCount = LngStart To LngEnd
    'Update the Record Number
    rngUpdate.Value = lngCount
    'Recalculate Worksheet (in case the user is in Manual Calculate Mode)
    rngUpdate.Worksheet.Calculate

    'If the user has specifed a Cell that contains a SheetName Tag,
    'Use it, else set it to Null
    If Not rngSheetName Is Nothing Then
        strSheetName = rngSheetName.Value
    Else
        strSheetName = vbNullString
    End If

    'If the SheetName tag is empty, create a Generic Name using the
    'Record Number
    If strSheetName = vbNullString Then
        strSheetName = shtTemplate.Name & "_" & _
                        Format(lngCount, String(Len(CStr(LngEnd)), "0"))
    End If

    'If the user wants the status bar to be updated, update it
    'with Record Number and Sheetname
    If booUpdateStatus Then
        Application.StatusBar = "Record " & _
                        Format(lngCount, String(Len(CStr(LngEnd)), "0")) & _
                        " of " & LngEnd & " | " & strSheetName
    End If

    'Export the Sheet using an Empty WorkBook argument to retain a reference
    'to the newly created WorkBook
    Call ExportSheetToBook(shtTemplate, wkbBook, strSheetName, True, _
                                booProtectSheet, strPwdSheet)

    'If the user has specifed a range that contains a FileName tag,
    'then use it. Else, set it to Null.
    If Not rngFileName Is Nothing Then
        strBookName = rngFileName.Value
    Else
        strBookName = ""
    End If

    'If the FileName tag is empty, create a Generic Name using the
    'Record Number
    If strBookName = "" Then
        strBookName = strSheetName
    End If

    'Update a String Variable to hold the full Path
    strBookPath = strOutputFolder & strBookName

    'Protect Workbook
    If booProtectBook Then
        wkbBook.Protect Password:=strPwdBook
    End If

    'Save the file
    If booSaveFile Then
        'If the user chooses to Password protect the file,
        'protect it with the specifed password
        If booProtectFile Then
            wkbBook.SaveAs FileName:=strBookPath, Password:=strPwdFile
        Else
            wkbBook.SaveAs FileName:=strBookPath
        End If
    End If

    'Print the worksheet
    If booPrint Then
        wkbBook.Worksheets(strSheetName).PrintOut
    End If

    'Close the File
    If booCloseFile Then
            wkbBook.Close
    End If

    'Set the WorkBook object to Nothing for the next iteration
    Set wkbBook = Nothing
Next lngCount

'Restore the StatusBar Message
If booUpdateStatus Then
    Application.StatusBar = False
End If

'Restore the Dsiplay Alerts Status
If booReplace Then
    Application.DisplayAlerts = booStatusAlerts
End If

'Show the user a Completed Message
If booPromptComplete Then
    Dim strMsgbox As String
    strMsgbox = "The Export is now done." & vbNewLine & _
                "Records " & LngStart & " to " & LngEnd & _
                " have been exported." & _
                vbNewLine & "The files are saved in : " & _
                strOutputFolder
    MsgBox strMsgbox, vbInformation
End If

End Sub

In fact, even in my application, I have used a macro that fetches all the arguments that need to be passed on to the aforementioned macros. I have added in detailed comments to help you follow my code.


Download

Download


Update

I extended this tool to handle upto 500 fields for a fellow struggler. Here is the link to that file. It has not been tested as much as I would have liked.

Download

In Excel 2016, users will find that they have numerous ways of organizing and visualizing their records. Making use of these options will allow you to put tables and charts together to create reports worthy of praise.

  • Basic chart and table creation
  • How to create PivotTables
  • How to create a Dashboard
  • Timelines and Slicers

Basic chart and table creation

Before you can impress your team with an in-depth report, you need to learn how to generate charts, tables, and other visual elements. Here are a few types to get you started.

How to create a basic forecast report

  1. Load a workbook into Excel
  2. Select the top-left cell in the source data
  3. Click on Data tab in the navigation ribbon
  4. Click on Forecast Sheet under the Forecast section to display the Create Forecast Worksheet dialog box
  5. Choose between a line graph or bar graph
  6. Choose Forecast end date
  7. Click Options for customization
  8. Select Forecast start date

Forecast reports are useful for calculating projections for sales, growth or revenue.

How to create hierarchal charts

  1. Select a cell inside of the data table
  2. Click on Insert in the ribbon
  3. Click Insert Hierarchy Chart under the Charts group
  4. Select between TreeMap or Sunburst chart
  5. Click on the + (plus) sign to add or remove chart elements such as title, data labels, and legend
  6. Click on the right arrow for each element to customize the appearance or behavior

The Charts group itself is an effective way to find the chart that best suits your data. In fact, Excel 2016 has a Recommended Charts option, which allows you to scroll through shortlisted charts or through all available charts.

How to create PivotTables

A PivotTables enable users to sort through and reorganize data in columns and rows in order to find the most effective view. It’s especially useful when you are working with vast amounts of data.

How to create a recommended P{ivotTable

  1. Select a cell within the table range or source data
  2. Navigate to the Tables section in the Insert ribbon tab
  3. Select Recommended PivotTable
  4. Browse through the presented types of PivotTables
  5. Click on the PivotTable you want
  6. Click OK to generate
  7. Select Seasonality options
  8. Modify timeline and value ranges
  9. Select to fill any missing points by zeros or by interpolation
  10. Select criteria to aggregate duplicates by
  11. Select Create to finish

How to create your own PivotTable

  1. Click on a cell within the source data or table range
  2. Click on the Insert tab in the navigation ribbon
  3. Select PivotTable in the Tables section to generate the Create PivotTable dialog box
  4. Decide on the data source in the Choose the data that you want to analyze section, in case you don’t want to use the selected source
  5. Select New or Existing Worksheet under the Choose where you want the PivotTable to be placed section
  6. Click Add this data to the Data Model to incorporate additional data sources in the PivotTable
  7. Click on fields to include in the report in the PivotTable Fields
  8. Click and drag fields to reside in either Filters, Columns, Rows, and Values

Once you have decided on the layout and contents of your PivotTable fields, you can use it as the foundation for other Pivot Tables.

How to create a Dashboard

Once you have become comfortable enough to generate charts and tables using your provided data, it’s time to begin piecing the story together in a dashboard. The Dashboard is your chance to showcase your data in an attractive, informative and insightful hub view. It provides a top-level view of the data, allowing your audience to quickly see data and trends in order to view results and make decisions. This reporting tool is highly adaptable and can be used to report a plethora of results regardless of your line of business.

How to prepare your PivotTables for the Dashboard

  1. Select the original PivotTable that wish to use as your master or reference table
  2. Right-click on the selection
  3. Choose Copy
  4. Select another cell on your worksheet
  5. Right-click on the selected cell
  6. Choose Paste to duplicate
  7. Repeat steps No. 4 to No. 6 as needed
  8. Click on PivotTable Tools for each table
  9. Click Analyze
  10. Insert a name in the PivotTable Name box to identify the function of each table

How to generate PivotCharts from PivotTables

  1. Select the original PivotTable
  2. Click on PivotTable Tools
  3. Select Analyze
  4. Select PivotChart
  5. Choose the type of chart that you need
  6. Choose formatting options in the PivotChart Tools tab
  7. Click on Analyze under PivotChart Tools
  8. Enter a name in the Chart Name box
  9. Apply steps No. 1 to No. 8 as needed for all PivotTables in use

Timelines and Slicers

With your multiple PivotCharts and PivotTables created, you’ll need to be able to find specific information that supports the details you wish to share in the dashboard. Slicers and Timelines provide a way to filter through the data with ease. Timelines allow you to filter by time to locate a specific period. Slicers are essentially click-to-filter options for PivotTables. Not only do they apply a filter, they also indicate the filter currently in use.

How to add a Slicer

  1. From a PivotTable click on PivotTable Tools
  2. Select Analyze
  3. Select Filter
  4. Select Insert Slicer
  5. Select the items to be used as slicers
  6. Click Ok
  7. Select a Slicer
  8. Click on Slicer Tools
  9. Select Options
  10. Select Report Connections
  11. Choose the PivotTables that connect to the chosen Slicer

How to add a Timeline

  1. Click on a PivotTable
  2. Select Analyze
  3. Select Filter
  4. Select Insert Timeline
  5. Click on the items to use in the Timeline
  6. Click on the Timeline
  7. Select Tools
  8. Select Options
  9. Select Report Connections
  10. Select PivotTables to link the Timeline to

With each resulting chart, you can choose to copy and paste it on your dashboard. You can then decide how the dashboard should appear, what will tell the best story for your report.

This results in a dynamic dashboard that allows recipients to look over your presented data while allowing them to sort through the data to give them customization options pertinent to them. If you are creating a Dashboard to be used on a regular basis, you only need to update the source data to recreate the report with new information.

Wrapping Up

There isn’t one report to rule them all, but Excel has the tools to help you make the report you need. How often do you have to create reports in Excel? Which one are you most proud of? Let us know in the comments. And be sure to visit our Office 101 help hub for more related articles!

  • Microsoft Office 101: Help, how-tos and tutorials

All the latest news, reviews, and guides for Windows and Xbox diehards.

Most Popular

Понравилась статья? Поделить с друзьями:
  • Generating random numbers excel
  • Generating qr codes from excel
  • Generate word with letters
  • Generate word from two words
  • Generate word from other words