<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ excel - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ excel - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Sun, 24 May 2026 16:30:41 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/excel/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ Learn the top Excel formulas and functions ]]>
                </title>
                <description>
                    <![CDATA[ Excel is one of the most powerful tools for data analysis, organization, and automation. Whether you're a student, business professional, or data analyst, mastering Excel formulas and functions can significantly boost your productivity. However, with... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/learn-the-top-excel-formulas-and-functions/</link>
                <guid isPermaLink="false">67e5643f0a2aebb29e2c2264</guid>
                
                    <category>
                        <![CDATA[ excel ]]>
                    </category>
                
                    <category>
                        <![CDATA[ youtube ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Beau Carnes ]]>
                </dc:creator>
                <pubDate>Thu, 27 Mar 2025 14:44:15 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1743086651754/1f008643-281a-452a-bc45-c8247f23ddb9.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Excel is one of the most powerful tools for data analysis, organization, and automation. Whether you're a student, business professional, or data analyst, mastering Excel formulas and functions can significantly boost your productivity. However, with so many functions available, it can be overwhelming to know which ones to use and when. If you've ever second-guessed yourself while working with Excel, this course will give you the confidence to use formulas effectively and streamline your workflow.</p>
<p>We just published a course on the <a target="_blank" href="http://freeCodeCamp.org">freeCodeCamp.org</a> YouTube channel that will teach you the top Excel formulas and functions you need to know. By the end of this course, you'll be able to apply these functions confidently, speed up your work, and eliminate confusion when choosing the right formula. Grant Huang developed this course.</p>
<p>The course starts by covering the fundamentals of cell referencing—an essential concept for writing effective formulas. You'll learn about relative referencing, which allows formulas to adjust dynamically when copied to other cells, and absolute referencing, which locks specific cells to prevent unwanted changes. Understanding these concepts is key to avoiding common mistakes and ensuring accurate calculations in your spreadsheets.</p>
<p>From there, you'll dive into essential Excel formulas such as:</p>
<ul>
<li><p><strong>Basic Arithmetic Operations</strong> (addition, subtraction, multiplication, and division)</p>
</li>
<li><p><strong>SUM and AVERAGE</strong> for quick calculations</p>
</li>
<li><p><strong>IF Statements</strong> for decision-making within formulas</p>
</li>
<li><p><strong>VLOOKUP and HLOOKUP</strong> for searching data efficiently</p>
</li>
<li><p><strong>INDEX and MATCH</strong> for more advanced lookups</p>
</li>
<li><p><strong>TEXT functions</strong> to manipulate and clean up data</p>
</li>
<li><p><strong>DATE and TIME functions</strong> for managing schedules and timelines</p>
</li>
<li><p><strong>LOGICAL functions</strong> like AND, OR, and NOT for conditional logic</p>
</li>
</ul>
<p>You'll also learn shortcuts and best practices to make your workflow more efficient. By applying these techniques, you can automate repetitive tasks, analyze data more effectively, and present your findings in a clear and professional manner.</p>
<p>Whether you're new to Excel or looking to refine your skills, this course is designed to be practical and easy to follow. Watch the full course below (75 minutes) or on the freeCodeCamp YouTube channel.</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/O3m9m6Ie4gY" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Automating a coffee shop chain using self-taught coding skills with Eamonn Cottrell [Interview #151] ]]>
                </title>
                <description>
                    <![CDATA[ On this week's episode of the podcast, I interview Eamonn Cottrell. He's a software engineer who also runs a local chain of coffee shops in Knoxville. Eamonn taught himself to code using freeCodeCamp. And he's since published 37 freeCodeCamp tutorial... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/self-taught-coding-automating-coffee-shop-chain-eamonn-cottrell-interview-151/</link>
                <guid isPermaLink="false">6740ac934465e258a6ed9ff7</guid>
                
                    <category>
                        <![CDATA[ learn to code ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Entrepreneurship ]]>
                    </category>
                
                    <category>
                        <![CDATA[ excel ]]>
                    </category>
                
                    <category>
                        <![CDATA[ running ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Quincy Larson ]]>
                </dc:creator>
                <pubDate>Fri, 22 Nov 2024 16:08:51 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1732291205597/f1fc0cf3-a295-43be-9dd7-ecc4784bd71a.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>On this week's episode of the podcast, I interview Eamonn Cottrell. He's a software engineer who also runs a local chain of coffee shops in Knoxville. Eamonn taught himself to code using freeCodeCamp. And he's since published 37 freeCodeCamp tutorials on productivity and automation using spreadsheets.</p>
<p>We talk about:</p>
<ul>
<li><p>Eamonn’s love of coffee and how he bought VHS tapes to learn latte art</p>
</li>
<li><p>How he finds time to expand his skills in between running coffee shops and ultra-marathoning</p>
</li>
<li><p>How he used spreadsheets to automate the logistics of running coffee shops</p>
</li>
<li><p>How he balances being a musician and writer with the practical realities of providing for a family of 6</p>
</li>
</ul>
<p>Can you guess what song I'm playing in the intro?</p>
<p>Support comes from the 11,113 kind folks who support freeCodeCamp through a monthly donation. Join these kind folks and get involved in our mission by going to <a target="_blank" href="http://donate.freecodecamp.org">donate.freecodecamp.org</a></p>
<p>CORRECTION: Vincent van Gogh was supported by his younger brother – not his brother in-law. van Gogh never married so he never had a brother in law. I'm not sure why I thought that. Also, he seems to have sold more than one painting in his life (as many of us were taught in school), but nowhere near enough paintings to support himself as an artist.</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/5MoZ1hJuvqM" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p> </p>
<p>Links we talk about during our conversation:</p>
<p>Eamonn's freeCodeCamp articles: <a target="_blank" href="https://www.freecodecamp.org/news/author/sieis/">https://www.freecodecamp.org/news/author/sieis/</a></p>
<p>Eamonn's YouTube channel: <a target="_blank" href="https://www.youtube.com/@eamonncottrell">https://www.youtube.com/@eamonncottrell</a></p>
<p>Excel-based esports: <a target="_blank" href="https://www.youtube.com/watch?v=N2QC6VQXo8U">https://www.youtube.com/watch?v=N2QC6VQXo8U</a></p>
<p>Ultra Marathons: <a target="_blank" href="https://www.youtube.com/@runtired">https://www.youtube.com/@runtired</a></p>
<p>Got Sheet: <a target="_blank" href="https://www.gotsheet.xyz/">https://www.gotsheet.xyz/</a></p>
<p>Progress and Perfection: <a target="_blank" href="https://www.progressandperfection.com/">https://www.progressandperfection.com/</a></p>
<p>Eamonn on LinkedIn: <a target="_blank" href="https://www.linkedin.com/in/eamonncottrell/">https://www.linkedin.com/in/eamonncottrell/</a></p>
<p>Eamonn on Twitter: <a target="_blank" href="https://x.com/EamonnCottrell">https://x.com/EamonnCottrell</a></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Microsoft Excel: 14 Time-Saving Keyboard Shortcuts ]]>
                </title>
                <description>
                    <![CDATA[ Microsoft Excel is the quintessential spreadsheet software used everywhere from universities to small businesses to enterprises. It’s a lifesaver for countless financial professionals, data analysts, and teachers. But it’s also one of those programs ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/microsoft-excel-keyboard-shortcuts/</link>
                <guid isPermaLink="false">670ead175b03d2b334e6560f</guid>
                
                    <category>
                        <![CDATA[ excel ]]>
                    </category>
                
                    <category>
                        <![CDATA[ spreadsheets ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Data Science ]]>
                    </category>
                
                    <category>
                        <![CDATA[ data analysis ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Eamonn Cottrell ]]>
                </dc:creator>
                <pubDate>Tue, 15 Oct 2024 17:57:43 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1728930420116/82fe0d9f-89fe-4332-82dc-43b44d4ee2dc.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Microsoft Excel is the quintessential spreadsheet software used everywhere from universities to small businesses to enterprises.</p>
<p>It’s a lifesaver for countless financial professionals, data analysts, and teachers. But it’s also one of those programs that virtually everyone in any role can benefit from learning.</p>
<p>A handful of shortcuts can go a long way in increasing your productivity (and enjoyment) while using Excel.</p>
<p>In this article, I’ll detail some of the many shortcuts that I have found helpful throughout my studies and career.</p>
<h3 id="heading-excel-shortcuts-well-cover">Excel Shortcuts We’ll Cover:</h3>
<ul>
<li><p><a class="post-section-overview" href="#heading-how-to-execute-shortcuts-in-excel">How to Execute Shortcuts in Excel</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-shortcut-to-create-a-table">Shortcut to Create a Table</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-shortcut-to-create-a-pivot-table">Shortcut to Create a Pivot Table</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-shortcut-to-autofit-column-sizes">Shortcut to AutoFit Column Sizes</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-shortcut-to-open-format-cells">Shortcut to Open Format Cells</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-shortcut-to-center-contents-of-cell">Shortcut to Center Contents of Cell</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-shortcut-to-fill-color">Shortcut to Fill Color</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-shortcut-to-fill-contents-down-or-right">Shortcut to Fill Contents Down (or Right)</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-shortcut-to-show-or-hide-gridlines">Shortcut to Show or Hide Gridlines</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-shortcut-to-show-all-formulas">Shortcut to Show all Formulas</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-shortcuts-for-navigation-in-excel">Shortcuts for Navigation in Excel</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-shortcut-to-open-the-autofilter-menu-in-excel">Shortcut to Open the AutoFilter Menu in Excel</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-shortcut-to-create-a-slicer-in-excel">Shortcut to Create a Slicer in Excel</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-shortcut-to-create-checkboxes-in-excel">Shortcut to Create Checkboxes in Excel</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-shortcut-to-create-charts-in-excel">Shortcut to Create Charts in Excel</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-other-notes">Other Notes</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-more-shortcuts">More Shortcuts</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-got-sheet">Got Sheet</a></p>
</li>
</ul>
<p>Here’s a video walkthrough of everything we’ll cover in this article:</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/RfFhh0n4bMM" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p> </p>
<h2 id="heading-how-to-execute-shortcuts-in-excel">How to Execute Shortcuts in Excel</h2>
<p>In Excel, the more you can learn to do without touching your mouse, the better. Often, by keeping your hands on your keyboard, you can save a lot of time in each project.</p>
<p>As such, virtually every command imaginable is available as a keyboard shortcut.</p>
<p>The basic ones like <code>CTRL + S</code> for save and <code>CTRL + C</code> for copy are present. But Excel goes a step further…</p>
<p>The real power comes from the <code>alt</code> shortcuts. By pressing sequences of keys that typically start with <code>alt</code>, almost all of the actions in the Ribbon become available.</p>
<p>By simply pressing the <code>alt</code> key, all of the shortcut sequences available from the current view become highlighted in yellow on the ribbon:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1728924144231/6b083a86-6db6-41e3-b960-4a06a5d3284f.png" alt="alt shortcuts in Excel" class="image--center mx-auto" width="1059" height="280" loading="lazy"></p>
<p>Incidentally, some of the shortcuts’ sequences are separated by commas, while at other times two letters appear next to each other. Their execution is the same. Simply press them in sequence.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1728925276816/8867e861-ecd7-43d9-989d-dab2fef62d8a.png" alt="one vs two letter shortcut sequences" class="image--center mx-auto" width="169" height="89" loading="lazy"></p>
<p>Below, you’ll find some of my favorites, but keep in mind that you can easily view all the available shortcuts at any time by pressing <code>alt</code> and then continuing to press the appropriate keys for the corresponding tabs and actions.</p>
<h2 id="heading-shortcut-to-create-a-table">Shortcut to Create a Table</h2>
<h3 id="heading-keyboard-shortcut-ctrl-t">Keyboard Shortcut: <code>ctrl + t</code></h3>
<p>Tables in Excel are often the preferred format to begin manipulating and visualizing data. As long as the active cell is inside your data range, pressing <code>ctrl + t</code> will pop up a dialog and automatically select the data range to be used for the table.</p>
<p>It is adjustable if Excel gets a column or row wrong, and you can also toggle table headers on or off from this initial box.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1728924526482/aa5ffdee-2327-4232-8a6d-c74e271f4bce.png" alt="create table in Excel" class="image--center mx-auto" width="342" height="204" loading="lazy"></p>
<h2 id="heading-shortcut-to-create-a-pivot-table">Shortcut to Create a Pivot Table</h2>
<h3 id="heading-keyboard-shortcut-alt-n-v-t">Keyboard shortcut: <code>alt + n, v, t</code></h3>
<p>Want to appear a lot smarter than you are? Learn the basics of pivot tables in ten minutes. Your coworkers will remain impressed for weeks.</p>
<p>To create a pivot table, simply click somewhere in your data range and press <code>ALT + n, v, t</code>.</p>
<p>Excel is smart enough to recognize the data range you likely want included even if it isn’t already formatted as a table.</p>
<p>A dialog box will pop up for you to confirm the data range and location for the pivot table.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1728924350920/21f22ae2-238c-4e73-9690-cbc538c46458.png" alt="21f22ae2-238c-4e73-9690-cbc538c46458" class="image--center mx-auto" width="635" height="357" loading="lazy"></p>
<h2 id="heading-shortcut-to-autofit-column-sizes">Shortcut to AutoFit Column Sizes</h2>
<h3 id="heading-keyboard-shortcut-alt-h-o-i">Keyboard Shortcut: <code>alt + h, o, i</code></h3>
<p>Ever get tired of resizing your columns so that the text in the cells doesn’t clip or spill? You can always double click the column boundary headings. This resizes the column to fit the widest cell’s contents.</p>
<p>The keyboard shortcut is much more efficient and allows you to autofit multiple columns in one fell swoop. Simply click and drag the column boundaries to select any number of columns. Execute the <code>alt + h, o, i</code> shortcut and all the columns in your active range will autofit their width.</p>
<p>You can also autofit cells individually by selecting one or more active cells and performing the same shortcut.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1728924664667/9611fe54-9d2f-442c-9246-a3ab85b1e81d.png" alt="autofit column width in Excel" class="image--center mx-auto" width="411" height="427" loading="lazy"></p>
<h2 id="heading-shortcut-to-open-format-cells">Shortcut to Open Format Cells</h2>
<h3 id="heading-keyboard-shortcut-ctrl-1-or-alt-h-fm">Keyboard Shortcut: <code>CTRL + 1</code> or <code>alt + h, fm</code></h3>
<p>Unless you are content with mediocrity, you’ll be formatting the cells in your spreadsheet at some point to create more readable, user-friendly content.</p>
<p>The simplest shortcut to open up the Format Cells window is <code>CTRL + 1</code>, although if you want to flex your dexterity, <code>alt + h, fm</code> will get you there as well.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1728925061866/0d773119-097f-479e-bcc5-5bb8ba311a5d.png" alt="Cell formatting options" class="image--center mx-auto" width="783" height="774" loading="lazy"></p>
<h2 id="heading-shortcut-to-center-contents-of-cell">Shortcut to Center Contents of Cell</h2>
<h3 id="heading-keyboard-shortcut-horizontal-alt-h-a-c">Keyboard Shortcut: (horizontal) <code>alt + h, a, c</code>,</h3>
<p>(vertical) <code>alt + h, a, m</code></p>
<p>We have it easy compared to web developers. There seems a never-ending supply of articles and videos reminding developers how to center <code>divs</code>.</p>
<p>In Excel, we need only remember two quick shortcuts.</p>
<ul>
<li><p>For horizontal centering: <code>alt + h, a, c</code></p>
</li>
<li><p>For vertical centering: <code>alt + h, a, m</code></p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1728925842812/56676126-976e-4f1d-bb8a-2bf7072f9342.png" alt="centering text in a cell in Excel" class="image--center mx-auto" width="453" height="372" loading="lazy"></p>
<p>There are other shortcuts for left, right, top and bottom alignment, but most of the time when we change the original alignment, it’s to center it.</p>
<h2 id="heading-shortcut-to-fill-color">Shortcut to Fill Color</h2>
<h3 id="heading-keyboard-shortcut-alt-h-h">Keyboard Shortcut: <code>alt + h, h</code></h3>
<p>For a quick highlight, it takes precious seconds to mouse up to the fill color icon. Pressing <code>alt + h, h</code> quickly toggles the color selection open.</p>
<p>Once it’s open, you can leave your mouse to the side and arrow down to your favorite color</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1728926023010/6cebdbc6-e27e-4784-8cc8-d46dbf8c4985.png" alt="fill color menu in Excel" class="image--center mx-auto" width="385" height="603" loading="lazy"></p>
<h2 id="heading-shortcut-to-fill-contents-down-or-right">Shortcut to Fill Contents Down (or Right)</h2>
<h3 id="heading-keyboard-shortcut-down-ctrl-d-right-ctrl-r">Keyboard Shortcut: (down) <code>CTRL + D</code>, (right) <code>CTRL + R</code></h3>
<p>One of the most powerful features of Excel is the ability to drag formulas and functions down or across many cells, effectively reproducing a single calculation many times on different pieces of data.</p>
<p>By typing a formula in cell A8 in the image below, we can then highlight A8 and drag down to our heart’s content. Then, by pressing <code>CTRL + D</code>, the formula will be copied down into every highlighted cell.</p>
<p>By default, it will also preserve the relative reference of the cell. In other words, the next cell will contain the formula <code>A7 + A8</code> and then <code>A8 + A9</code>, and so on.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1728927617121/35dd07d3-90ac-4c31-9318-1e588bff007c.png" alt="Dragging down" class="image--center mx-auto" width="1116" height="1349" loading="lazy"></p>
<h2 id="heading-shortcut-to-show-or-hide-gridlines">Shortcut to Show or Hide Gridlines</h2>
<h3 id="heading-keyboard-shortcut-alt-w-vg">Keyboard Shortcut: <code>alt + w, vg</code></h3>
<p>The mark of a real data analyst is not the quality of their reports, but the precision of their workbook. Gridlines have got to go. If you need lines, you can add borders.</p>
<p>Toggle off the gridlines with <code>alt + w, vg</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1728926496034/ab39e08c-1ac2-4d4d-986e-1c79597a322e.png" alt="Shortcut to toggle off gridlines" class="image--center mx-auto" width="332" height="158" loading="lazy"></p>
<p>And if you need those borders immediately, highlight your data range and press <code>alt + h, b</code> to open up the border menu. If you simply need all borders, <code>alt + h, b, a</code> will do the trick</p>
<h2 id="heading-shortcut-to-show-all-formulas">Shortcut to Show all Formulas</h2>
<h3 id="heading-keyboard-shortcut-ctrl">Keyboard Shortcut: <code>CTRL + ~</code></h3>
<p>You’ll likely never lose control of a workbook.</p>
<p>But in the event you access one of your less rigorous colleague’s workbooks and need to see what functions they’ve Frankensteined together, press <code>CTRL + ~</code> to display all the functions instead in the spreadsheet.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1728927250678/868f9daa-04d7-447c-b494-15fea77a4e1c.png" alt="display functions in Excel workbook" class="image--center mx-auto" width="807" height="709" loading="lazy"></p>
<h2 id="heading-shortcuts-for-navigation-in-excel">Shortcuts for Navigation in Excel</h2>
<h3 id="heading-keyboard-shortcuts-ctrl-arrow-keys-and-others">Keyboard Shortcuts: <code>CTRL + arrow keys</code> (and others)</h3>
<p>Navigating the grid can be very fast with the keyboard. Pressing <code>CTRL +</code> the <code>arrows</code>, the <code>home</code> and the <code>end</code> buttons will warp you all over the active sheet.</p>
<p>Using the <code>arrows</code> and <code>CTRL</code>, you go to the last nonblank cell in the row or column.</p>
<p>Using <code>CTRL + home or end</code>, you go to the beginning and the end of the workbook, respectively. (When inside a table, <code>home</code> and <code>end</code> take you to the beginning and end of the table only.)</p>
<h2 id="heading-shortcut-to-open-the-autofilter-menu-in-excel">Shortcut to Open the AutoFilter Menu in Excel</h2>
<h3 id="heading-keyboard-shortcut-alt-down-arrow">Keyboard Shortcut: <code>alt + down arrow</code></h3>
<p>Another superpower in Excel is the ease with which we can filter and sort large pieces of data. To access the AutoFilter Menu quickly, press <code>alt + down arrow</code> while in the header for the column you’d like to filter.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1728928353490/dcca3af8-2858-4ca0-abd6-d7e197826008.png" alt="auto-filter menu" class="image--center mx-auto" width="444" height="918" loading="lazy"></p>
<h2 id="heading-shortcut-to-create-a-slicer-in-excel">Shortcut to Create a Slicer in Excel</h2>
<h3 id="heading-keyboard-shortcut-alt-n-sf">Keyboard Shortcut: <code>alt + n, sf</code></h3>
<p>For an even more user-friendly method of sorting, you can insert a slicer directly onto the spreadsheet by pressing <code>alt + n, sf</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1728928617015/599d1bb7-4873-4f3d-aee2-6d478dcc034c.png" alt="Menu for inserting slicers" class="image--center mx-auto" width="536" height="556" loading="lazy"></p>
<h2 id="heading-shortcut-to-create-checkboxes-in-excel">Shortcut to Create Checkboxes in Excel</h2>
<h3 id="heading-keyboard-shortcut-alt-n-cb">Keyboard Shortcut: <code>alt + n, cb</code></h3>
<p>If you’re anything like me, you’ll find a way to use checkboxes in almost every spreadsheet you create. They’re extremely useful for toggling selections on and off in a workbook, and as of June 2024, Excel has made them available in production Excel.</p>
<p>Press <code>alt + n, cb</code> to insert a checkbox in a cell.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1728931963136/cc54e602-2d2c-4536-b07f-408f8404977d.png" alt="cc54e602-2d2c-4536-b07f-408f8404977d" class="image--center mx-auto" width="506" height="467" loading="lazy"></p>
<h2 id="heading-shortcut-to-create-charts-in-excel">Shortcut to Create Charts in Excel</h2>
<h3 id="heading-keyboard-shortcut-alt-n-r">Keyboard Shortcut: <code>alt + n, r</code></h3>
<p>There are a ton of chart types in Excel. To quickly open up the recommended charts dialog box, we can press <code>alt + n, r</code>.</p>
<p>Or, if we know we want a specific type of chart, there are multiple options to shortcut straight to them, like <code>alt + n, C1</code>, <code>alt + n, N1</code>, <code>alt + n, SA</code> and so on.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1729001331573/b9e240ba-6f42-4817-9d8c-e27241f66b18.png" alt="Chart types" class="image--center mx-auto" width="911" height="439" loading="lazy"></p>
<h2 id="heading-more-shortcuts">More Shortcuts</h2>
<p>There are a zillion shortcuts available in Excel. If you want to check out the full list, you can find a current version maintained by <a target="_blank" href="https://support.microsoft.com/en-us/office/keyboard-shortcuts-in-excel-1798d9d5-842a-42b8-9c99-9b7213f0040f">Microsoft here</a>.</p>
<h2 id="heading-got-sheet">Got Sheet</h2>
<p>Come join my free newsletter, <a target="_blank" href="https://www.gotsheet.xyz/subscribe">Got Sheet</a>. I show people how to get good at spreadsheets every week.</p>
<p>You can find me over on <a target="_blank" href="https://www.youtube.com/@eamonncottrell">YouTube</a> as well.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Excel for Data Visualization ]]>
                </title>
                <description>
                    <![CDATA[ Excel can be great for data visualization. We just published course on the freeCodeCamp.org YouTube channel that is a comprehensive guide to Excel data visualization and dashboard creation. This course is designed to equip you with the skills needed ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/excel-for-data-visualization/</link>
                <guid isPermaLink="false">66ce44fe8b02f6094dbea128</guid>
                
                    <category>
                        <![CDATA[ excel ]]>
                    </category>
                
                    <category>
                        <![CDATA[ youtube ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Beau Carnes ]]>
                </dc:creator>
                <pubDate>Tue, 27 Aug 2024 21:28:30 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1724861455582/2faf862b-dcac-4957-ad32-1f651406ed62.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Excel can be great for data visualization.</p>
<p>We just published course on the <a target="_blank" href="http://freeCodeCamp.org">freeCodeCamp.org</a> YouTube channel that is a comprehensive guide to Excel data visualization and dashboard creation. This course is designed to equip you with the skills needed to transform raw data into insightful visualizations and interactive dashboards using Microsoft Excel. Mihir from Office Tech Skill developed this course.</p>
<h3 id="heading-course-overview"><strong>Course Overview</strong></h3>
<p>This tutorial covers a wide range of Excel chart types and customization techniques, providing you with the tools to create engaging and informative dashboards. This course offers valuable insights into making the most of Excel's powerful features.</p>
<ul>
<li><p><strong>Introduction</strong>: Get an overview of what you'll learn and how these skills can be applied in real-world scenarios.</p>
</li>
<li><p><strong>Chart Types</strong>: Explore various chart types, including Column, Bar, Line, Pie/Doughnut, XY Scatter Plot, Area, Radar, Stock, Histogram, Pareto, Waterfall, Box &amp; Whisker, Treemap, and Map charts. Each section provides detailed instructions on when and how to use these charts effectively.</p>
</li>
<li><p><strong>Chart Customization</strong>: Learn how to organize data, choose the best chart type, and apply styles to enhance your visualizations. You'll also discover how to adjust chart elements and labels, enhance data labels and gridlines, and apply color themes and palettes.</p>
</li>
<li><p><strong>Advanced Techniques</strong>: Dive into more complex features like utilizing combination charts and secondary axes, incorporating trendlines, and applying various chart elements. This section also covers best practices for chart customization to ensure your visualizations are both effective and aesthetically pleasing.</p>
</li>
<li><p><strong>Excel Dashboard Creation</strong>: Transition from individual charts to comprehensive dashboards. Learn how to plan your dashboard, clean and organize data, build relationships, and write DAX (Data Analysis Expressions) for advanced data manipulation.</p>
</li>
<li><p><strong>Interactive Dashboards</strong>: Discover how to incorporate interactivity into your dashboards, making them more engaging and user-friendly. This includes building pivot tables, charts, KPIs (Key Performance Indicators), and incorporating interactive elements.</p>
</li>
<li><p><strong>Building Your Dashboard</strong>: Put all the pieces together to create a fully functional Excel dashboard. This section guides you through the process of integrating all the elements you've learned into a cohesive and interactive dashboard.</p>
</li>
<li><p><strong>Free Excel Course</strong>: As a bonus, access additional resources and materials to further enhance your Excel skills.</p>
</li>
</ul>
<h3 id="heading-why-excel"><strong>Why Excel?</strong></h3>
<p>Excel remains one of the most widely used tools for data analysis and visualization due to its accessibility and powerful features. Mastering Excel's charting and dashboard capabilities can significantly enhance your ability to communicate data insights effectively, whether for business presentations, academic projects, or personal use.</p>
<h3 id="heading-get-started-today"><strong>Get Started Today</strong></h3>
<p>With step-by-step guidance and practical examples, this course will help you become proficient in one of the most essential skills in today's data-driven world.</p>
<p>Watch the full course on the <a target="_blank" href="https://youtu.be/VV8iRJ-DS0A">freeCodeCamp.org YouTube channel</a> (1-hour watch).</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/VV8iRJ-DS0A" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Work with Tables in Excel vs Google Sheets ]]>
                </title>
                <description>
                    <![CDATA[ Google Sheets recently released an all new feature: tables. Well, new is a bit of an overstatement. Excel has had proper tables for many, many years, and it's been a point of contention in the spreadsheet community. In this article, I'll break down w... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/excel-vs-google-sheets-tables/</link>
                <guid isPermaLink="false">66b8dde70a89d796f29a16dd</guid>
                
                    <category>
                        <![CDATA[ excel ]]>
                    </category>
                
                    <category>
                        <![CDATA[ google sheets ]]>
                    </category>
                
                    <category>
                        <![CDATA[ spreadsheets ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Eamonn Cottrell ]]>
                </dc:creator>
                <pubDate>Tue, 02 Jul 2024 17:27:11 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2024/07/4.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Google Sheets recently released an all new feature: tables.</p>
<p>Well, <em>new</em> is a bit of an overstatement. Excel has had proper tables for many, many years, and it's been a point of contention in the spreadsheet community.</p>
<p>In this article, I'll break down what exactly tables are, why they're important, and then see how Google Sheet's new tables stack up against Microsoft Excel's.</p>
<p>Here is a video walkthrough of everything we'll cover:</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/vBp5mveYZZ4" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<h2 id="heading-whats-a-table">What's a Table?</h2>
<p>A table is a way of structuring and formatting data in a spreadsheet. It groups together rows and columns of data so that they can be more easily filtered, grouped, and analyzed.</p>
<p>Many people would look at the following bit of data and wrongly assume that it's already in a table.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/image-103.png" alt="Image" width="600" height="400" loading="lazy">
<em>Data in Excel</em></p>
<p>This is merely well organized rows and columns of data in Excel. Each column is a separate category of information, that is ids, names, emails, job titles, and salaries.</p>
<p>Each row represents one entry of that data. So, you'd put your id, name, email, job title and salary going left to right in a row.</p>
<p>Simple, yes?</p>
<p>A table contains all the same data, but by formatting it as a table we can unlock a whole lot of additional functionality.</p>
<p>The first of which is the appearance itself. When we create a table, Excel immediately colors our data with a dark header row and bands of alternating colors.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/image-104.png" alt="Image" width="600" height="400" loading="lazy">
<em>Table in Excel</em></p>
<p>Sheets does the same thing, as we can see below.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/image-105.png" alt="Image" width="600" height="400" loading="lazy">
<em>Table in Google Sheets</em></p>
<p>So, a table is simply a way of managing and grouping data more easily. But it goes much further than just formatting, as we'll see.</p>
<h2 id="heading-why-are-tables-important">Why are Tables Important?</h2>
<p>Tables help reduce errors. When dealing with data, we are always making sure the data is clean and that we don't have errors in our formulas. </p>
<p>Tables help keep things orderly simply by being structured and formatted well. But as we'll see in the formula section in a moment, they also allow us to reduce errors in formulas by dynamically calculating things for us</p>
<h2 id="heading-how-to-create-a-table-in-excel-and-sheets">How to Create a Table in Excel and Sheets</h2>
<p>In Microsoft Excel, creating a table is as easy as clicking anywhere in the data range and pressing <code>CTRL + T</code>. Immediately, Excel will predict the data range for the table and ask you to confirm this.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/image-106.png" alt="Image" width="600" height="400" loading="lazy">
<em>Excel table data range</em></p>
<p>Alternatively, you can find the same create table option from the Insert Menu in the Ribbon at the top.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/table.png" alt="Image" width="600" height="400" loading="lazy">
<em>Excel insert menu</em></p>
<p>Over in Sheets, you'll need to either right click in a cell in the data range, or select the option from the Format menu to Convert to Table.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/sheets.png" alt="Image" width="600" height="400" loading="lazy">
<em>Convert to table options in Google Sheets</em></p>
<p>One caveat in Sheets: if you right click in a cell, you have to select the whole data range for it to convert to a table. Whereas, if you select Format - Convert to table from the menu, it is (like Excel) smart enough to predict the whole data range.</p>
<p>A small thing. But Excel takes the prize for ease of creation.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/right-click.png" alt="Image" width="600" height="400" loading="lazy">
<em>Convert to table in Google Sheets</em></p>
<p><strong>⭐Winner: EXCEL</strong></p>
<h2 id="heading-how-to-format-tables-in-excel-and-sheets">How to Format Tables in Excel and Sheets</h2>
<p>As we saw initially, some formatting is done as soon as we create a table.</p>
<p>From here, though, both programs allow for further customization.</p>
<p>In Sheets, we can select the dropdown in the top left next to the table name to access a few options immediately. For the most part, we can simply change the alternating colors of the table.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/sheets-format.png" alt="Image" width="600" height="400" loading="lazy">
<em>Formatting options in Google Sheets</em></p>
<p>If we select Custom, it opens up the full alternating colors menu that is also accessible through the Format menu. This gives us more control over the colors, but it's all aesthetic.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/image-110.png" alt="Image" width="600" height="400" loading="lazy">
<em>Alternating colors menu in Google Sheets</em></p>
<p>Meanwhile in Excel, we have the same options with a few more toggle selections for styling. For instance, we can check the first column to bold the text in the id column or we toggle between banded columns and/or rows.</p>
<p>And on the far right of the Table Design tab in the Ribbon, there are a ton of prebuilt styles that we can toggle on and off.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/format-excel.png" alt="Image" width="600" height="400" loading="lazy">
<em>Table design in Excel</em></p>
<p>Both programs give plenty of options here, and this is mostly to make the tables look good. But Excel comes out on top with more options.</p>
<p><strong>⭐Winner: EXCEL</strong></p>
<h2 id="heading-how-to-sort-tables-in-excel-and-google-sheets">How to Sort Tables in Excel and Google Sheets</h2>
<p>In both programs, there is a dropdown toggle button in each of the header row's cells. Selecting this in Excel allows us to sort ascending or descending...or even by color.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/sort.png" alt="Image" width="600" height="400" loading="lazy">
<em>sort in excel</em></p>
<p>For instance, if we have some of our data using a blue font color, we can actually sort it by that color:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/sort-color.png" alt="Image" width="600" height="400" loading="lazy">
<em>Sort by color in Excel</em></p>
<p>What about Google Sheets? Yep, same deal there. It will also detect when different colors are used and allow you to do the same type of sorting.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/sheets-sorting-options-1.png" alt="Image" width="600" height="400" loading="lazy">
<em>Sort by color in Sheets</em></p>
<p>Excel does have a Custom Sorting dialog box that can drill down into more detail. For instance, you can add levels of sorting.</p>
<p>Using our color example, we can first sort by the blue font colors in the email color and then by the red font colors in the job title column.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/double-sort.png" alt="Image" width="600" height="400" loading="lazy">
<em>Multiple column sorting in Excel</em></p>
<p>Google Sheets can do the same thing, but not from the header drop downs. The header drop down sorting is restricted to one row at a time in Sheets.</p>
<p>But, if you select the entire table's data range and then <code>Data - Sort Range - Advanced range sorting options</code>, you are able to sort by multiple columns in Google Sheets.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/advanced-sort-google-sheets.png" alt="Image" width="600" height="400" loading="lazy">
<em>Advanced sorting in Google Sheets</em></p>
<p>Sheets' advanced sorting is not as powerful as Excel's, though. You are only able to sort ascending or descending by value. Excel takes the cake on this one by a hair.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/google-sheets-muiltiple-row-sorting.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><strong>⭐Winner: EXCEL</strong></p>
<h2 id="heading-how-to-filter-tables-in-excel-and-google-sheets">How to Filter Tables in Excel and Google Sheets</h2>
<p>Filtering works exactly the same as sorting. In both programs, click the dropdown selector in the header row to see the options for filtering.</p>
<p>In both programs, we have the same options. We can filter by color just like in our sorting. We can filter by values by either selecting all, none, or individual values. And we can filter by condition.</p>
<p>Here's Google Sheet's menu:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/image-113.png" alt="Image" width="600" height="400" loading="lazy">
<em>Filtering in Google Sheets</em></p>
<p>And here's Excel's menu. All the same options are available. Both programs allow for custom filter formulas to be entered as well.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/image-112.png" alt="Image" width="600" height="400" loading="lazy">
<em>Filtering in Excel</em></p>
<p><strong>⭐Winner: TIE</strong></p>
<h2 id="heading-how-to-use-tables-in-formulas-in-excel-and-google-sheets">How to Use Tables in Formulas in Excel and Google Sheets</h2>
<p>One of the big reasons to use tables lies in formulas. Whether you use Excel or Sheets, you are likely taking advantage of built-in functions and the ability to create custom formulas for analyzing your data.</p>
<p>By holding your data in a table, your formulas can reference that data dynamically.</p>
<p>Meaning, if you add rows of data to your table, any formulas referencing those table values will update automatically.</p>
<p>The risk of breaking things by adding data decreases dramatically with the use of tables.</p>
<p>Here's a simple example. If we wanted to combine the first and last names into one cell, we could concatenate them with this formula <code>=Salary[first_name]&amp;" "&amp;Salary[last_name]</code>.</p>
<p>In Excel, we reference a table by its name, in this case, <code>Salary</code>. Then within brackets, we reference a column name, <code>[last_name]</code>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/image-115.png" alt="Image" width="600" height="400" loading="lazy">
<em>Spill formula in Excel</em></p>
<p>We can do the exact same in Sheets.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/image-116.png" alt="Image" width="600" height="400" loading="lazy">
<em>Formula referencing in Sheets</em></p>
<p>There's one powerful difference, though. In Excel, the formula will spill down. Meaning, we only have to write it once at the very top, but because it sees that we're referencing values in a table, it will spill down to every row in the table.</p>
<p>In Google Sheets, we still have to drag the formula down.</p>
<p>Now, sometimes, we may not want things to spill down. In this case we can use different syntax in Excel. Instead of the column name within brackets, we can add an @ sign and another set of brackets. This tells Excel to only make the calculation on one row: </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/image-117.png" alt="Image" width="600" height="400" loading="lazy">
<em>Formula referencing in Excel</em></p>
<p>Excel flexes on this one. It's much more powerful to use tables in formulas in Excel than in Sheets.</p>
<p><strong>⭐Winner: EXCEL</strong></p>
<h2 id="heading-how-to-change-table-range-in-excel-and-google-sheets">How to Change Table Range in Excel and Google Sheets</h2>
<p>What if we want to extend our table or remove data from it? Both Google Sheets and Excel allow us to do this easily.</p>
<p>Say we want to add a column for the full name of a person. In both programs, if we simply type in <code>full_name</code> in G1 to the right of our last column, that column will become a part of the table's data range.</p>
<p>Anytime we type in an adjacent column or row to our table data, the programs will assume the table needs to extend to include it.</p>
<p>Then, we can use a version of the formula from our previous example to insert the full names. Now that we are inside of the table, though, it's not necessary to include the title of the table in our formula.</p>
<p>Now, all that's needed in Excel is <code>=[@[first_name]]&amp;" "&amp;[@[last_name]]</code>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/image-119.png" alt="Image" width="600" height="400" loading="lazy">
<em>Reference table columns in Excel</em></p>
<p>For Google Sheets, it's the same inside the table as outside it: <code>=Table2[first]&amp;" "&amp;Table2[last]</code>. Sheets also requires us to drag the formula down. It does not handle spilling like Excel (yet).</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/image-118.png" alt="Image" width="600" height="400" loading="lazy">
<em>Reference table columns in Sheets</em></p>
<p>To add columns within a table, we can right click the column name and select insert.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/image-120.png" alt="Image" width="600" height="400" loading="lazy">
<em>Insert column in Excel</em></p>
<p>Google has a slight edge here in that you can select whether to insert to the left or the right, whereby Excel only inserts to the left.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/image-121.png" alt="Image" width="600" height="400" loading="lazy">
<em>Insert column Google Sheets</em></p>
<p>Inserting rows is exactly the same. Excel allows for inserting rows above, while Sheets allows you to select above or below.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/image-122.png" alt="Image" width="600" height="400" loading="lazy">
<em>Inserting rows Google Sheets</em></p>
<p>In both programs, deleting rows and columns is as simple as selecting the row(s) or column(s), right clicking, and selecting delete.</p>
<p>In Excel you have the added benefit of a keyboard shortcut. <code>CTRL + -</code> will delete the selected rows or columns.</p>
<p>Both programs will also allow you to convert a table back to a regular data range. In Excel, it's the <code>Convert to Range</code> button in the <code>Table Design</code> tab of the menu</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/07/convert.png" alt="Image" width="600" height="400" loading="lazy">
<em>Convert to Range option in Excel</em></p>
<p>And in Google Sheets, it's the <code>Revert to unformatted data</code> option from the table dropdown menu.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/07/revert.png" alt="Image" width="600" height="400" loading="lazy">
<em>Revert to unformatted data option in Sheets</em></p>
<p><strong>⭐Winner: TIE</strong></p>
<h2 id="heading-how-to-add-a-total-row-in-a-table">How to Add a Total Row in a Table</h2>
<p>There's a good chance you'll want to total up the amounts in a column. How easy is this to add in a table?</p>
<p>You can do it in both programs, but...</p>
<p>Excel makes it incredibly easy. There's a toggle option for this in the Table Design menu in the Ribbon. Toggle this on, and a Total row is automatically included and calculated at the bottom.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/total-row.png" alt="Image" width="600" height="400" loading="lazy">
<em>Total row in Excel</em></p>
<p>Can you do the same in Sheets? </p>
<p>Yes, you've just got to do it yourself.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/06/image-124.png" alt="Image" width="600" height="400" loading="lazy">
<em>Total row in Sheets</em></p>
<p><strong>⭐Winner: EXCEL</strong></p>
<h2 id="heading-who-wins">Who Wins?</h2>
<p>Well, it's no surprise that Excel comes out on top. Sheets users (myself included) have a lot to be excited about with the ability to finally create proper tables. By and large, the functionality is just as powerful as Excel. </p>
<p>And much like many features compared between the two programs, Sheets can probably get the job done for most use cases.</p>
<p>Excel, as per normal, simply does more and does it a little bit better.</p>
<p>I'm Eamonn, and I'll help you <strong>get good at spreadsheets</strong>. Join my free newsletter, <a target="_blank" href="https://www.gotsheet.xyz/subscribe">Got Sheet, here</a>.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Analyze and Visualize Large Datasets with Microsoft Excel Using Pivot Tables and Charts ]]>
                </title>
                <description>
                    <![CDATA[ By Samuel A. Olubiyo Microsoft Excel is a very powerful tool that you can use to analyze and visualize data.  In this tutorial, you will learn how to build a simple Excel Dashboard that visualizes important data from a large dataset.  The dataset we'... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/analyze-and-visualize-large-datasets-with-excel-pivot-tables-charts/</link>
                <guid isPermaLink="false">66d4601347a8245f78752a81</guid>
                
                    <category>
                        <![CDATA[ data analysis ]]>
                    </category>
                
                    <category>
                        <![CDATA[ data visualization ]]>
                    </category>
                
                    <category>
                        <![CDATA[ excel ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Fri, 05 Jan 2024 17:40:39 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2024/01/all-charts-with-conditional-formatting-1.PNG" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Samuel A. Olubiyo</p>
<p>Microsoft Excel is a very powerful tool that you can use to analyze and visualize data. </p>
<p>In this tutorial, you will learn how to build a simple Excel Dashboard that visualizes important data from a large dataset. </p>
<p>The dataset we'll be working with is the transaction records of a super store for a period of four years. Our goal is to gain important insights from the dataset and visualize those insights graphically with Microsoft Excel.</p>
<p>This tutorial is tailored for those who are already familiar with Excel. In it, you will learn:</p>
<ul>
<li>How to format dates in Excel using the TEXT function.</li>
<li>How to sort the entire data set.</li>
<li>How to create multiple Pivot Tables on the same worksheet</li>
<li>How to create charts based on the Pivot Table.</li>
<li>How to create slicers to filter data, and finally,</li>
<li>How to use conditional formatting.</li>
</ul>
<p>In order to make the most of this tutorial, I have provided a data set for you to use. You can <a target="_blank" href="https://github.com/Lordsamdev/superstoredata/blob/main/Super%20Store%20Dataset.xlsx">download it here</a>.</p>
<p>If you're new to data analysis and visualization with Excel, the freeCodeCamp website contains a lot of tutorials for beginners. <a target="_blank" href="https://www.freecodecamp.org/news/tag/excel/">Here is a link to some articles on Excel from beginner to advanced</a> if you need to brush up on your skills.</p>
<h2 id="heading-our-dataset">Our Dataset</h2>
<p>After downloading the Excel file and opening it, you will notice one thing instantly: The data is huge! It is a data set containing the transactions of a superstore for a period of four years (from 2014 to 2017). </p>
<p>This Excel file is made up of 9995 rows and 21 columns. We can’t gain any useful insights from this data set just by staring at it, which is why we need to analyze and visualize it.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/Data-Overview.PNG" alt="Image" width="600" height="400" loading="lazy">
<em>Screenshot of the dataset</em></p>
<p>The easiest way to do this is by using Pivot Tables. A Pivot Table is one of Microsoft Excel's powerful tools you can use to calculate, analyze and summarize data. It helps you see comparisons, trends, and patterns in your data and you will learn how to use it in this tutorial.</p>
<p>Before we continue, let's take a look at the data set again: column C contains the order dates for each product sold. The order date column is important in this tutorial, because we need to sort the entire dataset based on the dates each customer ordered a product.</p>
<h2 id="heading-how-to-format-dates-in-excel-using-the-text-function">How to Format Dates in Excel Using the TEXT Function.</h2>
<p>In our dataset, the dates are arranged haphazardly and the date formatting makes it hard to tell exactly when each customer ordered a product. To fix this, we'll use the TEXT function to convert the dates to text.</p>
<p>Before you do this, insert a new column beside column C. This will be your new column D and where the newly formatted dates will reside. You can give it a new name – in my own case, I named it “Formatted Dates.”</p>
<p>After that is done, insert the formula in the screenshot below and press enter:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/formatting-a-date.PNG" alt="Image" width="600" height="400" loading="lazy">
<em>Formula to convert dates into text</em></p>
<p>Or just copy and paste the formula below:</p>
<p>=TEXT(C2, "d mmmm yyyy")</p>
<p>Of course, the formula only works for the first cell in the column. To repeat it across the entire column, just double-tap the little node at the right end of the cell when it's highlighted (as you can see in the below screenshot):</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/flash-fill-node.PNG" alt="Image" width="600" height="400" loading="lazy">
<em>Tap on the node to fill the remaining cells in the column automatically</em></p>
<p>Now, you should have dates in a more readable format across column D.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/formatted-date-column.PNG" alt="Image" width="600" height="400" loading="lazy">
<em>The dates in a more readable format</em></p>
<p>For the purpose of this analysis, we need to extract the years from the dates we have just formatted. To do this, create a new column beside column D, this will be your new column E. Name the column as you like, but in my case, I named it “Year”.</p>
<p>Now use the formula in the screenshot below and press enter:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/getting-the-year.PNG" alt="Image" width="600" height="400" loading="lazy">
<em>Formula to get the year from the date</em></p>
<p>Or simply copy and paste the formula below:</p>
<p>=RIGHT(D2,4)</p>
<p>This will extract the year at the end of the date. Double-tap the node at the end of the cell to repeat it across the entire column. You should get a similar result as shown in the screenshot below:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/The-year.PNG" alt="Image" width="600" height="400" loading="lazy">
<em>Screenshot showing the extracted year</em></p>
<h2 id="heading-how-to-sort-the-entire-dataset">How to Sort the Entire Dataset</h2>
<p>The next step in this tutorial is to sort the entire data set based on the newly extracted Year column.</p>
<p>Highlight the entire Year column and go to the sort tab, as you can see in the screenshot below:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/The-sort-tab.PNG" alt="Image" width="600" height="400" loading="lazy">
<em>Sorting the dataset</em></p>
<p>Leave all options at default and press OK.</p>
<p>Now the entire data set should be sorted.</p>
<h2 id="heading-how-to-create-multiple-pivot-tables-on-the-same-worksheet">How to Create Multiple Pivot Tables on the Same Worksheet</h2>
<p>The next step in this tutorial is to create the pivot tables we'll use to make sense of this data.</p>
<p>Go to the insert tab and click on Pivot Table. A dialogue box should pop up asking you for the range of the data you want the pivot table to be created from – which by default is the entire data set.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/pivot-table-creation.PNG" alt="Image" width="600" height="400" loading="lazy">
<em>Creating a Pivot Table</em></p>
<p>You will also have options to use the existing worksheet to create the pivot table or a new worksheet. Select the <em>new worksheet</em> option and press OK.</p>
<p>You should have a result like you can see in the screenshot below:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/pivot-table-worksheet.PNG" alt="Image" width="600" height="400" loading="lazy">
<em>The Pivot Table Worksheet</em></p>
<p>From here things start to get interesting.</p>
<p>For this exercise, I am only interested in three things: </p>
<ul>
<li>The category of products with the highest sales for each of the four years (2014 to 2017)</li>
<li>Which sub-category has the highest sales </li>
<li>Which region drives the most sales to this super store.</li>
</ul>
<p>I also want to visualize this information using graphs and charts. Thankfully, Excel has the tools we need to achieve all these.</p>
<p>In case you don’t know how to create a Pivot Table, here is a comprehensive <a target="_blank" href="https://www.freecodecamp.org/news/how-to-create-a-pivot-table-in-excel/">freeCodeCamp article</a> teaching you how to do that.</p>
<p>So we need to create three Pivot Tables, one for the sales by category, one for the sales by sub-category, and one for the sales by region.</p>
<p>To create the first table, simply select sales and category from the PivotTable Fields at the right hand side of your screen.</p>
<p>After creating the first Pivot Table, to add another table on the same worksheet, simply go to the insert tab and click on Pivot Table, then go to the original worksheet with the dataset and highlight everything, click OK.</p>
<p>Repeat the step to create the last table for the sales by region.</p>
<p>You should have three tables as shown in the screenshot below:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/All-pivot-tables-1.PNG" alt="Image" width="600" height="400" loading="lazy">
<em>Screenshot showing all three Pivot Tables</em></p>
<h2 id="heading-how-to-create-charts-based-on-the-pivot-table">How to Create Charts Based on the Pivot Table</h2>
<p>The next step is to create the charts to visualize what is represented in the Pivot Tables. This is quite straightforward – just highlight each table and click the insert tab to insert the chart of your choice.</p>
<p>I used a pie chart for the sales by category table, and column charts for the other two tables on the worksheet. But you can use whatever chart(s) you want.</p>
<p>If you follow my steps exactly, you should have a result similar to the screenshot below:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/All-charts-and-tables.PNG" alt="Image" width="600" height="400" loading="lazy">
<em>Screenshot showing all the charts</em></p>
<h2 id="heading-how-to-create-slicers-to-filter-data">How to Create Slicers to Filter Data</h2>
<p>The next step is to use slicers to filter each table by the year so that we can see what the total sales for each category, sub-category, and region are by year.</p>
<p>To do this, highlight each table and click on the analyze tab, then click on the slicer button as shown in this screenshot:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/insert-slicer.PNG" alt="Image" width="600" height="400" loading="lazy">
<em>Creating a slicer</em></p>
<p>You'll see a list of options. Look for Year, and click it.</p>
<p>Now you should have a slicer for the years 2014 to 2017. Clicking on the corresponding button for each year will filter the table and show the sales for the year. Here is what it should look like:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/All-charts-with-slicers.PNG" alt="Image" width="600" height="400" loading="lazy">
<em>Screenshot showing all the slicers</em></p>
<h2 id="heading-how-to-use-conditional-formatting">How to Use Conditional Formatting</h2>
<p>Finally, you can use conditional formatting to indicate the highest and lowest values on each table. You can play around with this as you like.</p>
<p>To use conditional formatting, click on the conditional formatting tab, and use this screenshot as a guide:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/conditional-formatting.PNG" alt="Image" width="600" height="400" loading="lazy">
<em>Using conditional formatting</em></p>
<p>Highlight the values you would like to use conditional formatting for. I used the color scales option to indicate the highest and lowest values by different colors, then I used the data bars option for the sales by sub-category table.</p>
<p>If you did exactly what I did, you should have something close to the screenshot below:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/all-charts-with-conditional-formatting.PNG" alt="Image" width="600" height="400" loading="lazy">
<em>The completed dashboard</em></p>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>This little project we have built together can be expanded to get more insights into the data set, this can prove very useful when making business decisions. </p>
<p>This dashboard we have built has revealed that the best selling category is electronics and the best selling sub-category is phones. I also learned that the most sales came from the western region just by glancing at this dashboard.</p>
<p>I hope this tutorial has been helpful. Here is <a target="_blank" href="https://github.com/Lordsamdev/superstoredata/blob/main/Super%20Store%20Tutorial.xlsx">the link</a> to the completed version of this project – you can compare it with what you have built and see how well you did.</p>
<p>If you have any questions, you can reach out to me on <a target="_blank" href="https://twitter.com/thelordsamdev">X</a> and <a target="_blank" href="https://www.linkedin.com/in/lordsamdev/">LinkedIn</a>. Thanks for reading.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Automate Data Exports and Email Reports with Python – a Step-by-Step Guide ]]>
                </title>
                <description>
                    <![CDATA[ In today's data-driven world, automation is key to streamlining tasks and saving time. In this beginner-friendly tutorial, I'll walk you through the process of automating data exports from a PostgreSQL database and sending them as an email attachment... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/automate-data-exports-email-reports-with-python/</link>
                <guid isPermaLink="false">66ba0e68d14c87384322b68d</guid>
                
                    <category>
                        <![CDATA[ automation ]]>
                    </category>
                
                    <category>
                        <![CDATA[ excel ]]>
                    </category>
                
                    <category>
                        <![CDATA[ postgres ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Python ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ashutosh Krishna ]]>
                </dc:creator>
                <pubDate>Mon, 30 Oct 2023 16:08:37 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/10/report-automation.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In today's data-driven world, automation is key to streamlining tasks and saving time. In this beginner-friendly tutorial, I'll walk you through the process of automating data exports from a PostgreSQL database and sending them as an email attachment using Python. </p>
<p>This step-by-step guide will help you grasp the fundamentals of working with databases, data manipulation, and email communication, all while automating these processes with a Python script.</p>
<h2 id="heading-business-context">Business Context</h2>
<p>Imagine you're a part of an organization where your managers expect a weekly report filled with valuable insights. But creating this report is far from a straightforward task. </p>
<p>To get the information you need, you have to manually run ten different database queries, gather the results, and then meticulously compile them into an Excel spreadsheet. It's a time-consuming and error-prone process that can leave you exhausted.</p>
<p>In this scenario, wouldn't it be a game-changer if Python could take the reins and handle this entire process for you? </p>
<p>Picture this: Every week, without any manual intervention, Python seamlessly extracts the required data, compiles it into a neat Excel sheet, and even sends it off to your managers like clockwork. </p>
<p>This tutorial will help you learn how to do this. I'll walk you through the steps to automate this process, making your weekly or monthly reporting a breeze, and freeing you up to focus on more critical tasks.</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ol>
<li><a class="post-section-overview" href="#heading-prerequisites">Prerequisites</a></li>
<li><a class="post-section-overview" href="#heading-how-to-set-up-your-virtual-environment">How to Set Up Your Virtual Environment</a></li>
<li><a class="post-section-overview" href="#heading-how-to-set-up-your-sample-database">How to Set Up Your Sample Database</a></li>
<li><a class="post-section-overview" href="#heading-how-to-set-up-logging-and-environment-variables">How to Set Up Logging and Environment Variables</a></li>
<li><a class="post-section-overview" href="#heading-how-to-extract-the-data-from-the-database">How to Extract the Data From the Database</a></li>
<li><a class="post-section-overview" href="#heading-how-to-structure-the-booking-data-with-the-bookinginfo-class">How to Structure the Booking Data with the <code>BookingInfo</code> Class</a></li>
<li><a class="post-section-overview" href="#heading-how-to-convert-the-data-into-an-excel-sheet">How to Convert the Data into an Excel Sheet</a></li>
<li><a class="post-section-overview" href="#heading-how-to-combine-the-functionalities">How to Combine the Functionalities</a></li>
<li><a class="post-section-overview" href="#heading-how-to-send-an-email-with-the-bookings-data-report">How to Send an Email with the Bookings Data Report</a></li>
<li><a class="post-section-overview" href="#heading-how-to-test-the-flow">How to Test the Flow</a></li>
<li><a class="post-section-overview" href="#heading-how-to-schedule-the-application">How to Schedule the Application</a></li>
<li><a class="post-section-overview" href="#heading-wrapping-up">Wrapping Up</a></li>
</ol>
<h2 id="heading-prerequisites">Prerequisites</h2>
<p>Before you get started, make sure you have the following:</p>
<ol>
<li>Python installed on your computer. You can download Python from <a target="_blank" href="https://www.python.org/downloads/">Python.org</a>.</li>
<li>Basic knowledge of the Python programming language</li>
<li>Familiarity with <a target="_blank" href="https://blog.ashutoshkrris.in/how-to-send-emails-using-python">sending emails in Python</a></li>
<li>PostgreSQL installed on your computer. You can download PostgreSQL from <a target="_blank" href="https://www.postgresql.org/download/">here</a>.</li>
</ol>
<h2 id="heading-how-to-set-up-your-virtual-environment">How to Set Up Your Virtual Environment</h2>
<p>Before you start coding, you'll need to make sure you have all the necessary tools and libraries installed. </p>
<p>To ensure that you have a clean and isolated environment, you'll <a target="_blank" href="https://www.freecodecamp.org/news/how-to-setup-virtual-environments-in-python/">create a virtual environment</a> using <code>venv</code>.</p>
<p>Create a project directory and navigate to it in the terminal:</p>
<pre><code class="lang-bash">mkdir report-automation
<span class="hljs-built_in">cd</span> report-automation
</code></pre>
<p>Create a virtual environment named <code>env</code> using the following command:</p>
<pre><code class="lang-bash">python -m venv env
</code></pre>
<p>Python now ships with the pre-installed <code>venv</code> library to create virtual environments.</p>
<p>Activate the virtual environment like this:</p>
<pre><code class="lang-bash"><span class="hljs-built_in">source</span> env/bin/activate
</code></pre>
<p>Note: if you're on Windows, you'll need to use <code>source env/Scripts/activate</code> to activate the environment.</p>
<p>You should see <code>(env)</code> in your terminal prompt, indicating that the virtual environment has been activated.</p>
<h3 id="heading-how-to-install-the-required-libraries">How to Install the Required Libraries</h3>
<p>Now that you've created the virtual environment, you can install the following libraries:</p>
<ul>
<li><code>psycopg2</code>: Python adapter for PostgreSQL, enabling Python applications to interact with PostgreSQL databases.</li>
<li><code>pandas</code>: A versatile data manipulation and analysis library for Python, ideal for working with structured data.</li>
<li><code>xlsxwriter</code>: Python module for creating and formatting Excel (XLSX) files, useful for generating reports and spreadsheets.</li>
</ul>
<p>To install the libraries, run the following command:</p>
<pre><code class="lang-bash">pip install psycopg2 pandas xlsxwriter
</code></pre>
<h2 id="heading-how-to-set-up-your-sample-database">How to Set Up Your Sample Database</h2>
<p>In this section, I will guide you through setting up a demo database named "airlines" that we'll use throughout this tutorial. The database includes three tables: <code>bookings</code>, <code>flights</code>, and <code>airports_data</code>. </p>
<p>I will provide you with an SQL script file named <code>airlines_db.sql</code> that creates the database and populates it with sample data. To set up the database, you will need PostgreSQL installed on your system.</p>
<h3 id="heading-download-and-install-the-database">Download and Install the Database</h3>
<ol>
<li>Download the SQL script file "airlines_db.sql" from <a target="_blank" href="https://drive.google.com/file/d/1CPo4ZC8dmuyCetEwpyDa6pfKnpbiqyO3/view?usp=sharing">here</a>.</li>
<li>Open your terminal or command prompt.</li>
<li>Use the following command to install the database. Make sure you have the PostgreSQL command-line tools installed and that you can access the <code>psql</code> command. Replace <code>postgres</code> with your PostgreSQL username if it's different.</li>
</ol>
<pre><code class="lang-bash">psql -f airlines_db.sql -U postgres
</code></pre>
<p>This command will execute the SQL script and create the "airlines" database with the <code>bookings</code>, <code>flights</code>, and <code>airports_data</code> tables.</p>
<h3 id="heading-schema-description">Schema Description</h3>
<p>The main schema in the database is <code>bookings</code>. Let's take a closer look at the tables in the "airlines" database:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/Screenshot-2023-10-29-115228.png" alt="Image" width="600" height="400" loading="lazy">
<em>Schema Diagram</em></p>
<h4 id="heading-table-bookingsbookings">Table <code>bookings.bookings</code></h4>
<p>The "bookings" table is designed to store crucial information about bookings made for flights. Each booking is uniquely identified by the <code>book_ref</code>, which is a <code>character(6)</code> field. The <code>total_amount</code> field is a <code>numeric(10,2)</code> type and represents the total cost of the booking. </p>
<p>To track the booking date and time, the table includes a <code>book_date</code> field of type <code>bigint</code>. This table serves as the central repository for booking data and is essential for tracking passenger reservations, costs, and booking dates.</p>
<h4 id="heading-table-bookingsflights">Table <code>bookings.flights</code></h4>
<p>The "flights" table is dedicated to capturing comprehensive details about flights, including information about their statuses, scheduled and actual times of departure and arrival, and other important flight-related data. </p>
<p>The primary key for this table is the <code>flight_id</code>, an <code>integer</code> identifier. Each flight is associated with a specific flight number denoted by the <code>flight_no</code> field, a <code>character(6)</code> type. </p>
<p>To understand the flight's origin and destination, the <code>departure_airport</code> and <code>arrival_airport</code> fields store the departure and arrival airport codes as <code>character(3)</code> types, respectively. </p>
<p>The <code>status</code> field is a <code>character varying(20)</code> that records the flight's status, which must be one of 'On Time,' 'Delayed,' 'Departed,' 'Arrived,' 'Scheduled,' or 'Cancelled.' The table also includes fields for scheduled departure and arrival times (<code>scheduled_departure</code> and <code>scheduled_arrival</code>) and actual departure and arrival times (<code>actual_departure</code> and <code>actual_arrival</code>). </p>
<p>Furthermore, this table establishes two essential foreign keys: <code>flights_arrival_airport_fkey</code> and <code>flights_departure_airport_fkey</code>, which link to the <code>airport_code</code> in the "airports_data" table. This establishes connections between flights and their respective departure and arrival airports.</p>
<h4 id="heading-table-bookingsairportsdata">Table <code>bookings.airports_data</code></h4>
<p>The "airports_data" table serves as a repository for data related to airports and their geographic locations. Each airport is identified by a unique <code>character(3)</code> code stored in the <code>airport_code</code> field, which also serves as the primary key. </p>
<p>The <code>timezone</code> field, of type <code>text</code>, records the specific timezone of the airport, providing essential information for scheduling and operational purposes. The <code>airport_name</code> field is a <code>character varying</code> type that holds the name of the airport. Additionally, the table includes the <code>city</code> field as a <code>character varying</code> type, indicating the city in which the airport is situated. </p>
<p>These details enable the "airports_data" table to provide a comprehensive overview of airport locations and information. This serves as a reference for the "flights" table through the <code>flights_arrival_airport_fkey</code> and <code>flights_departure_airport_fkey</code> foreign keys, facilitating the association between flights and their respective departure and arrival airports.</p>
<h2 id="heading-how-to-set-up-logging-and-environment-variables">How to Set Up Logging and Environment Variables</h2>
<p>In this section, we'll configure logging to provide informative messages and handle errors throughout the code. We'll also set up environment variables to securely store sensitive information and configuration parameters. These practices enhance code readability, maintainability, and security.</p>
<h3 id="heading-logging-configuration">Logging Configuration</h3>
<p>We will utilize Python's built-in <code>logging</code> module to configure a logging system. Logging is essential for tracking the execution flow of the code and capturing important information or errors. </p>
<p>The <code>logging.basicConfig</code> method is called to define the format of log messages and set the logging level to <code>INFO</code>.</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> logging

logging.basicConfig(
    format=<span class="hljs-string">"%(asctime)s | %(levelname)s : %(message)s"</span>, level=logging.INFO
)
</code></pre>
<ul>
<li><strong>Format</strong>: The <code>format</code> parameter specifies the format of log messages. In this case, each log entry includes a timestamp, log level (for example, INFO, ERROR), and the actual log message.</li>
<li><strong>Log Levels</strong>: We set the logging level to <code>INFO</code>, which means the logger will record informational messages. You can also use higher severity levels, such as <code>WARNING</code> or <code>ERROR</code>, for more critical issues.</li>
</ul>
<p>You can learn more about logging in Python in <a target="_blank" href="https://earthly.dev/blog/logging-in-python/">this tutorial</a>.</p>
<h3 id="heading-how-to-manage-environment-variables">How to Manage Environment Variables</h3>
<p>We will create a <code>.env</code> file to manage environment variables. Environment variables are used to store sensitive information and configuration settings, allowing us to keep such data separate from the code. </p>
<p>In this case, we set environment variables for email credentials and database connection details.</p>
<pre><code><span class="hljs-keyword">export</span> EMAIL=
<span class="hljs-keyword">export</span> PASSWORD=
<span class="hljs-keyword">export</span> EMAIL_PORT=<span class="hljs-number">587</span>
<span class="hljs-keyword">export</span> SMTP_SERVER=smtp.gmail.com
<span class="hljs-keyword">export</span> DB_HOSTNAME=localhost
<span class="hljs-keyword">export</span> DB_NAME=airlines
<span class="hljs-keyword">export</span> DB_PORT=<span class="hljs-number">5432</span>
<span class="hljs-keyword">export</span> DB_USERNAME=postgres
<span class="hljs-keyword">export</span> DB_PASSWORD=postgres
</code></pre><p>Here's a breakdown of the variables:</p>
<ul>
<li><strong>EMAIL</strong>: The email address to be used for sending emails.</li>
<li><strong>PASSWORD</strong>: The password associated with the email account.</li>
<li><strong>EMAIL_PORT</strong>: The port for the email server (for example, SMTP server). The default is 587 for secure email transmission (TLS/SSL).</li>
<li><strong>SMTP_SERVER</strong>: The SMTP server address, often specific to the email service provider.</li>
<li><strong>DB_HOSTNAME</strong>: The hostname or IP address of the PostgreSQL database server.</li>
<li><strong>DB_NAME</strong>: The name of the PostgreSQL database.</li>
<li><strong>DB_PORT</strong>: The port number for connecting to the database (default is 5432 for PostgreSQL).</li>
<li><strong>DB_USERNAME</strong>: The username for authenticating with the database.</li>
<li><strong>DB_PASSWORD</strong>: The password for the database user.</li>
</ul>
<p>Make sure you run <code>source .env</code> to load the environment variables.</p>
<p>By using environment variables, sensitive data like passwords and email credentials can be kept separate from the code, reducing the risk of accidental exposure or unauthorized access. The code can access these variables at runtime, ensuring security and flexibility in configuration.</p>
<h2 id="heading-how-to-extract-the-data-from-the-database">How to Extract the Data From the Database</h2>
<p>Let's start by setting the database configurations.</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> logging
<span class="hljs-keyword">import</span> os

logging.basicConfig(
    format=<span class="hljs-string">"%(asctime)s | %(levelname)s : %(message)s"</span>, level=logging.INFO
)

DB_CONFIG = {
    <span class="hljs-string">"host"</span>: os.environ.get(<span class="hljs-string">"DB_HOSTNAME"</span>),
    <span class="hljs-string">"database"</span>: os.environ.get(<span class="hljs-string">"DB_NAME"</span>),
    <span class="hljs-string">"user"</span>: os.environ.get(<span class="hljs-string">"DB_USERNAME"</span>),
    <span class="hljs-string">"password"</span>: os.environ.get(<span class="hljs-string">"DB_PASSWORD"</span>),
}
</code></pre>
<p>The <code>DB_CONFIG</code> dictionary is used to store the configuration parameters for connecting to the PostgreSQL database. These parameters include the host, database name, username, and password. These values can be set through environment variables.</p>
<h3 id="heading-how-to-connect-to-the-database">How to Connect to the Database</h3>
<p>Before we extract the data from the database, we need to connect to our database. We will use the <code>psycopg2</code> library to connect to the PostgreSQL database.</p>
<p>We will start by defining a <code>DataExporter</code> class that will contain methods to extract the database and generate the Excel sheet.</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">DataExporter</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self</span>):</span>
        <span class="hljs-string">"""Initialize the DataExporter with the database configuration."""</span>
        self.db_config = DB_CONFIG
</code></pre>
<p>The class constructor initializes the <code>DataExporter</code> with the database configuration stored in the <code>DB_CONFIG</code> <a target="_blank" href="https://blog.ashutoshkrris.in/everything-you-need-to-know-about-python-dictionaries">dictionary</a>.</p>
<p>Next, let's define a method that connects to the database.</p>
<pre><code class="lang-python">...
<span class="hljs-keyword">import</span> psycopg2

...

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">DataExporter</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self</span>):</span>
        <span class="hljs-string">"""Initialize the DataExporter with the database configuration."""</span>
        self.db_config = DB_CONFIG

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__connect_to_database</span>(<span class="hljs-params">self</span>) -&gt; <span class="hljs-keyword">None</span>:</span>
        <span class="hljs-string">"""
        Establish a connection to the PostgreSQL database.

        Raises:
            Exception: If a connection to the database cannot be established.
        """</span>
        <span class="hljs-keyword">try</span>:
            self.conn = psycopg2.connect(**self.db_config)
            self.cursor = self.conn.cursor()
            logging.info(<span class="hljs-string">"Connected to the database"</span>)
        <span class="hljs-keyword">except</span> Exception <span class="hljs-keyword">as</span> e:
            logging.error(
                <span class="hljs-string">"Failed to connect to the database with error: %s"</span>, e)
            <span class="hljs-keyword">raise</span>
</code></pre>
<p>The <code>__connect_to_database</code> private method is responsible for establishing a connection to the PostgreSQL database. It uses the <code>psycopg2</code> library to create a connection and a cursor for executing SQL queries. If the connection fails, it logs an error and raises an exception.</p>
<p>You can learn more about exception handling in Python <a target="_blank" href="https://blog.ashutoshkrris.in/exception-handling-in-python">here</a>.</p>
<h3 id="heading-how-to-fetch-data-from-the-database">How to Fetch Data from the Database</h3>
<p>Now we'll define another private method that connects to the database and fetches the total number of bookings and the total amount from the database.</p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> datetime <span class="hljs-keyword">import</span> datetime

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">DataExporter</span>:</span>
    ...

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__fetch_from_database</span>(<span class="hljs-params">self, start_timestamp, end_timestamp</span>) -&gt; list | <span class="hljs-keyword">None</span>:</span>
        <span class="hljs-string">"""
        Fetch booking data from the database for a given time range.

        Args:
            start_timestamp (datetime): The start of the time range.
            end_timestamp (datetime): The end of the time range.

        Returns:
            list: A list containing booking data (num_bookings, total_amount) or None if an error occurs.
        """</span>
        self.__connect_to_database()
        query = <span class="hljs-string">f"""
        SELECT COUNT(*) AS num_bookings, SUM(total_amount) AS total_amount
        FROM bookings
        WHERE book_date &gt;= <span class="hljs-subst">{int(start_timestamp.timestamp()) * <span class="hljs-number">1000</span>}</span> AND book_date &lt;= <span class="hljs-subst">{int(end_timestamp.timestamp()) * <span class="hljs-number">1000</span>}</span>
        """</span>
        logging.info(
            <span class="hljs-string">"Exracting bookings data from database for start timestamp=%s and end_timestamp=%s"</span>,
            start_timestamp,
            end_timestamp,
        )
        result = <span class="hljs-literal">None</span>
        <span class="hljs-keyword">try</span>:
            self.cursor.execute(query)
            result = list(self.cursor.fetchone())
            result.append(
                <span class="hljs-string">f'<span class="hljs-subst">{start_timestamp.strftime(<span class="hljs-string">"%d %b, %Y"</span>)}</span> - <span class="hljs-subst">{end_timestamp.strftime(<span class="hljs-string">"%d %b, %Y"</span>)}</span>'</span>
            )
            logging.info(
                <span class="hljs-string">"Successfully exracted bookings data from database for start timestamp=%s and end_timestamp=%s"</span>,
                start_timestamp,
                end_timestamp,
            )
        <span class="hljs-keyword">except</span> Exception <span class="hljs-keyword">as</span> e:
            logging.error(
                <span class="hljs-string">"Error occurred while extracting bookings data from database: %s"</span>, e
            )
        <span class="hljs-keyword">return</span> result
</code></pre>
<p>This private method retrieves booking data from the database for a specified time range. </p>
<p>It takes two <code>datetime</code> objects as arguments, <code>start_timestamp</code> and <code>end_timestamp</code>. It also constructs a SQL query to retrieve the count of bookings and the total booking amount for that time range. </p>
<p>The query is executed, and if it's successful, the method returns the data as a tuple. We convert the tuple into a list and append the timeframe for which data was extracted to the list. If an error occurs during the database interaction, it logs an error and returns <code>None</code>.</p>
<p>Using the above method, you can extract booking data for various timeframes, whether it's for a week, a month, a year, or any custom time range of your choice.</p>
<h2 id="heading-how-to-structure-the-booking-data-with-the-bookinginfo-class">How to Structure the Booking Data with the <code>BookingInfo</code> Class</h2>
<p>In this section, we will define a <code>BookingInfo</code> class in <code>booking_info.py</code>, which serves as a structured container for booking data retrieved from the database. The class encapsulates booking-related information, making it easier to work with and present the data. </p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> decimal <span class="hljs-keyword">import</span> Decimal


<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">BookingInfo</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, data_list: list</span>):</span>
        <span class="hljs-string">"""
        Initialize BookingInfo with data from the database.

        Args:
            data_list (list): A list containing booking data (total_bookings, total_amount, timestamp).

        Note:
            The total_amount is converted to a Decimal type.

        """</span>
        self.__total_bookings, self.__total_amount, self.__timestamp = data_list
        self.__total_amount = Decimal(self.__total_amount) <span class="hljs-keyword">if</span> self.__total_amount <span class="hljs-keyword">else</span> Decimal(<span class="hljs-number">0</span>)

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__str__</span>(<span class="hljs-params">self</span>) -&gt; str:</span>
        <span class="hljs-string">"""
        Return a string representation of BookingInfo.

        Returns:
            str: A string in the format "Total Bookings: X, Total Amount: $Y".

        """</span>
        <span class="hljs-keyword">return</span> <span class="hljs-string">f"Total Bookings: <span class="hljs-subst">{self.__total_bookings}</span>, Total Amount: $<span class="hljs-subst">{self.__total_amount}</span>"</span>

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">get_total_bookings</span>(<span class="hljs-params">self</span>) -&gt; int:</span>
        <span class="hljs-string">"""
        Get the total number of bookings.

        Returns:
            int: The total number of bookings.

        """</span>
        <span class="hljs-keyword">return</span> self.__total_bookings

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">get_total_amount</span>(<span class="hljs-params">self</span>) -&gt; Decimal:</span>
        <span class="hljs-string">"""
        Get the total booking amount as a Decimal.

        Returns:
            Decimal: The total booking amount.

        """</span>
        <span class="hljs-keyword">return</span> self.__total_amount

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">get_timestamp</span>(<span class="hljs-params">self</span>) -&gt; str:</span>
        <span class="hljs-string">"""
        Get the timestamp associated with the booking data.

        Returns:
            str: The timestamp as a string.

        """</span>
        <span class="hljs-keyword">return</span> self.__timestamp
</code></pre>
<p>The <code>BookingInfo</code> class is designed to organize and represent booking data returned from the database. It receives a list of values containing total bookings, total booking amount, and a timestamp as input and converts the total amount to a Decimal type. The class offers methods for accessing and presenting this data in a structured manner.</p>
<p>The constructor of the <code>BookingInfo</code> class takes a <code>data_list</code> as input, which is expected to be a list containing the following elements:</p>
<ul>
<li><code>total_bookings</code>: An integer representing the total number of bookings.</li>
<li><code>total_amount</code>: A floating-point value representing the total booking amount.</li>
<li><code>timestamp</code>: A timestamp associated with the booking data.</li>
</ul>
<p>The <code>__init__</code> method initializes private instance variables (<code>__total_bookings</code>, <code>__total_amount</code>, and <code>__timestamp</code>) with the values from the <code>data_list</code>. It also converts the <code>__total_amount</code> to a decimal type for precise handling of monetary values.</p>
<p>The <code>__str__</code> method is implemented to provide a string representation of the <code>BookingInfo</code> object. It returns a string in the format "Total Bookings: X, Total Amount: $Y", where <code>X</code> is the total number of bookings and <code>Y</code> is the total booking amount formatted as dollars.</p>
<h3 id="heading-getter-methods">Getter Methods</h3>
<p>The class provides three getter methods to access the encapsulated data:</p>
<ul>
<li><code>get_total_bookings()</code>: Returns the total number of bookings as an integer.</li>
<li><code>get_total_amount()</code>: Returns the total booking amount as a Decimal type.</li>
<li><code>get_timestamp()</code>: Returns the timestamp associated with the booking data as a string.</li>
</ul>
<p>By encapsulating the booking data within the <code>BookingInfo</code> class, the code is more organized, readable, and reusable. This structured approach simplifies the handling of booking information throughout the application, making it more intuitive to work with and present the data.</p>
<h2 id="heading-how-to-convert-the-data-into-an-excel-sheet">How to Convert the Data into an Excel Sheet</h2>
<p>Now that you can retrieve data from the database for a specific time range, you can also generate an Excel sheet based on the extracted data. </p>
<p>To do this, let's define another private method to create the Excel sheet.</p>
<pre><code class="lang-python">...
<span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd

<span class="hljs-keyword">from</span> booking_info <span class="hljs-keyword">import</span> BookingInfo


...

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">DataExporter</span>:</span>

    ...

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__convert_to_excelsheet</span>(<span class="hljs-params">self, data: list, sheet_name: str</span>):</span>
        <span class="hljs-string">"""
        Convert the fetched data into an Excel sheet.

        Args:
            data (list): A list containing booking data.
            sheet_name (str): Name of the Excel sheet to be created.

        Raises:
            ValueError: If there is an error in converting data to an Excel sheet.
        """</span>
        <span class="hljs-keyword">try</span>:
            booking_info = BookingInfo(data)
            data = {
                <span class="hljs-string">""</span>: [<span class="hljs-string">"Total Bookings"</span>, <span class="hljs-string">"Total Amount ($)"</span>],
                booking_info.get_timestamp(): [
                    booking_info.get_total_bookings(),
                    booking_info.get_total_amount(),
                ],
            }
            logging.info(<span class="hljs-string">"Converting the data into pandas dataframe"</span>)
            df = pd.DataFrame(data)
            logging.info(<span class="hljs-string">"Inserting the data into the excelsheet"</span>)
            <span class="hljs-keyword">with</span> pd.ExcelWriter(sheet_name, engine=<span class="hljs-string">"xlsxwriter"</span>) <span class="hljs-keyword">as</span> writer:
                df.to_excel(writer, sheet_name=<span class="hljs-string">"Sheet1"</span>, index=<span class="hljs-literal">False</span>)
            logging.info(<span class="hljs-string">"Successfully inserted data into the excelsheet"</span>)
        <span class="hljs-keyword">except</span> ValueError <span class="hljs-keyword">as</span> e:
            logging.error(<span class="hljs-string">"Error converting data into excel: %s"</span>, e)
</code></pre>
<p>The <code>__convert_to_excelsheet</code> method within the <code>DataExporter</code> class is responsible for structuring and converting extracted booking data into an Excel sheet. </p>
<p>It accepts two input parameters. The first parameter, <code>data</code>, is expected to be a list containing specific booking data. This data includes the total number of bookings, the total booking amount, and a timestamp for which data was extracted. The second parameter, <code>sheet_name</code>, represents the desired name for the Excel sheet that will contain the formatted data.</p>
<p>A key aspect of the method is the structuring of the data. To achieve this, the method initiates the creation of a <code>BookingInfo</code> object, referred to as <code>booking_info</code>. The <code>BookingInfo</code> object provides a structured representation of the booking data, which simplifies the subsequent formatting and presentation.</p>
<p>Following the creation of the <code>booking_info</code> object, a new dictionary called <code>data</code> is generated. This dictionary is designed to structure the data in a format suitable for conversion into an Excel sheet. </p>
<p>The dictionary consists of two key-value pairs:</p>
<ul>
<li>The first pair uses an empty string as the key and contains a list with two header values, "Total Bookings" and "Total Amount ($)".</li>
<li>The second pair uses the timestamp obtained from <code>booking_info.get_timestamp()</code> as the key and includes a list with two elements: the total number of bookings (<code>booking_info.get_total_bookings()</code>) and the total booking amount (<code>booking_info.get_total_amount()</code>).</li>
</ul>
<p>This dictionary allows the data to be inserted in the excel sheet as below:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/Screenshot-2023-10-29-135512.png" alt="Image" width="600" height="400" loading="lazy">
<em>Sample Excel Sheet</em></p>
<p>Then, the structured <code>data</code> dictionary is converted into a pandas DataFrame, referred to as <code>df</code>. Dataframes are a commonly used data structures for handling tabular data in Python. This step streamlines the manipulation and export of the data for further processing or visualization. </p>
<p>To create the Excel sheet, the code uses the <code>pd.ExcelWriter</code> context manager with the "xlsxwriter" engine. This context manager ensures that the Excel file is appropriately prepared for data insertion. The <code>sheet_name</code> parameter is supplied to specify the name of the sheet within the Excel file.</p>
<p>The data within the DataFrame, <code>df</code>, is then written to the Excel sheet. The <code>to_excel</code> method is used in conjunction with the <code>writer</code> object, and the <code>index</code> parameter is set to <code>False</code>. This specific configuration excludes the default row numbers that are typically included in Excel sheets.</p>
<h2 id="heading-how-to-combine-the-functionalities">How to Combine the Functionalities</h2>
<p>Now let's write a public method that the users can use to extract the data from the database and convert the extracted data into the Excel sheet file.</p>
<pre><code class="lang-python">...


<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">DataExporter</span>:</span>

    ...

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">generate_excelsheet</span>(<span class="hljs-params">
        self,
        start_timestamp: datetime,
        end_timestamp: datetime,
        sheet_name: str = <span class="hljs-string">"Bookings Data.xlsx"</span>,
    </span>) -&gt; bool:</span>
        <span class="hljs-string">"""
        Generate an Excel sheet with booking data for a specified time range.

        Args:
            start_timestamp (datetime): The start of the time range.
            end_timestamp (datetime): The end of the time range.
            sheet_name (str, optional): Name of the Excel sheet to be created. Defaults to "Bookings Data.xlsx".

        Returns:
            bool: True if excelsheet was generated successfully else False

        Note:
            This method logs errors but does not raise exceptions to avoid breaking the workflow.
        """</span>
        data = self.__fetch_from_database(start_timestamp, end_timestamp)
        <span class="hljs-keyword">if</span> data <span class="hljs-keyword">is</span> <span class="hljs-keyword">not</span> <span class="hljs-literal">None</span>:
            self.__convert_to_excelsheet(data, sheet_name)
            <span class="hljs-keyword">return</span> <span class="hljs-literal">True</span>
        <span class="hljs-keyword">else</span>:
            logging.error(<span class="hljs-string">"No data to convert generate excelsheet"</span>)
            <span class="hljs-keyword">return</span> <span class="hljs-literal">False</span>
</code></pre>
<p>This method accepts several parameters, including <code>start_timestamp</code> and <code>end_timestamp</code>, which define the beginning and end of the time period for data extraction. There's also an optional <code>sheet_name</code> parameter that allows the user to specify the name of the Excel sheet. By default, the sheet is named "Bookings Data.xlsx" to provide a convenient default option.</p>
<p>Upon execution, the method initiates the data retrieval process by calling the <code>__fetch_from_database</code> method, an internal private method of the class, with the specified time range. </p>
<p>If the data retrieval is successful and data is available, the method proceeds to call the <code>__convert_to_excelsheet</code> method. This structures and formats the data for insertion into the Excel sheet. </p>
<p>If, on the other hand, no data is available for the provided time range, the method logs an error message and returns "False" to indicate that the Excel sheet generation was unsuccessful.</p>
<h2 id="heading-how-to-send-an-email-with-the-bookings-data-report">How to Send an Email with the Bookings Data Report</h2>
<p>In this section, you will learn how you can <a target="_blank" href="https://blog.ashutoshkrris.in/how-to-send-emails-using-python">use Python to send an email</a> with a bookings data report as an attachment.</p>
<p>Create a <code>mailer.py</code> file and add the following content:</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> logging
<span class="hljs-keyword">import</span> os
<span class="hljs-keyword">import</span> smtplib
<span class="hljs-keyword">import</span> ssl

<span class="hljs-keyword">from</span> email <span class="hljs-keyword">import</span> encoders
<span class="hljs-keyword">from</span> email.mime.base <span class="hljs-keyword">import</span> MIMEBase
<span class="hljs-keyword">from</span> email.mime.multipart <span class="hljs-keyword">import</span> MIMEMultipart
<span class="hljs-keyword">from</span> email.mime.text <span class="hljs-keyword">import</span> MIMEText

logging.basicConfig(
    format=<span class="hljs-string">"%(asctime)s | %(levelname)s : %(message)s"</span>, level=logging.INFO
)

SMTP_SERVER = os.environ.get(<span class="hljs-string">"SMTP_SERVER"</span>)
PORT = os.environ.get(<span class="hljs-string">"EMAIL_PORT"</span>)
EMAIL = os.environ.get(<span class="hljs-string">"EMAIL"</span>)
PASSWORD = os.environ.get(<span class="hljs-string">"PASSWORD"</span>)


<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">send_email</span>(<span class="hljs-params">to_email: str, subject: str, attachment_name: str</span>):</span>
    <span class="hljs-string">"""
    Send an email with an attachment to the specified recipient.

    Args:
        to_email (str): The recipient's email address.
        subject (str): The subject of the email.
        attachment_name (str): The filename of the attachment.

    Note:
        This function assumes that the SMTP server requires TLS encryption.

    Raises:
        smtplib.SMTPException: If there is an issue with sending the email.

    """</span>
    message = MIMEMultipart()
    message[<span class="hljs-string">"From"</span>] = EMAIL
    message[<span class="hljs-string">"To"</span>] = to_email
    message[<span class="hljs-string">"Subject"</span>] = subject
    body = <span class="hljs-string">"Hi there\n\nPlease find attached your report.\n\nThanks"</span>

    message.attach(MIMEText(body, <span class="hljs-string">"plain"</span>))

    <span class="hljs-keyword">with</span> open(attachment_name, <span class="hljs-string">"rb"</span>) <span class="hljs-keyword">as</span> file:
        part = MIMEBase(
            <span class="hljs-string">"application"</span>, <span class="hljs-string">"vnd.openxmlformats-officedocument.spreadsheetml.sheet"</span>
        )
        part.set_payload(file.read())

    encoders.encode_base64(part)

    part.add_header(
        <span class="hljs-string">"Content-Disposition"</span>,
        <span class="hljs-string">f"attachment; filename= <span class="hljs-subst">{attachment_name}</span>"</span>,
    )

    logging.info(<span class="hljs-string">f"Attaching <span class="hljs-subst">{attachment_name}</span> to the email"</span>)
    message.attach(part)
    text = message.as_string()

    context = ssl.create_default_context()
    <span class="hljs-keyword">with</span> smtplib.SMTP(SMTP_SERVER, PORT) <span class="hljs-keyword">as</span> server:
        logging.info(<span class="hljs-string">f"Sending email to <span class="hljs-subst">{to_email}</span>"</span>)
        server.starttls(context=context)
        server.login(EMAIL, PASSWORD)
        server.sendmail(EMAIL, to_email, text)
        logging.info(<span class="hljs-string">f"Successfully sent the email to <span class="hljs-subst">{to_email}</span>"</span>)
</code></pre>
<p>As usual, we have configured the logger and environment variables in our script. </p>
<p>The core functionality is encapsulated within the <code>send_email</code> function. This function takes three parameters:</p>
<ol>
<li><code>to_email</code>: The recipient's email address.</li>
<li><code>subject</code>: The subject of the email.</li>
<li><code>attachment_name</code>: The filename of the attachment, which should be the bookings data report in this context.</li>
</ol>
<p>Within the function, we construct an email message using the <code>MIMEMultipart</code> class. This message includes the sender's email address, recipient's email address, subject, and a plain text body with a simple message.</p>
<p>The script allows attaching the bookings data report as an attachment. It reads the attachment file, encodes it, and adds it to the email message. This ensures that the recipient can easily access and download the data report from the email.</p>
<p>You can learn how you can add attachments while sending emails using Python <a target="_blank" href="https://blog.ashutoshkrris.in/how-to-send-emails-using-python#heading-including-attachments">here</a>.</p>
<p>The <code>create_default_context</code> function from the <code>ssl</code> library creates a secure SSL context for email communication. Finally, the script connects to the SMTP server, logs in using the sender's email address and password, sends the email, and logs a success message upon successful transmission.</p>
<h2 id="heading-how-to-test-the-flow">How to Test the Flow</h2>
<p>Let's finally test the flow of the application.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/finally-about-time.gif" alt="Image" width="600" height="400" loading="lazy"></p>
<p>In this section, we will automate the monthly reports. Create a <code>main.py</code> file and add the following content:</p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> exporter <span class="hljs-keyword">import</span> DataExporter
<span class="hljs-keyword">from</span> datetime <span class="hljs-keyword">import</span> datetime
<span class="hljs-keyword">from</span> mailer <span class="hljs-keyword">import</span> send_email

start_timestamp = datetime(<span class="hljs-number">2023</span>, <span class="hljs-number">5</span>, <span class="hljs-number">28</span>, <span class="hljs-number">00</span>, <span class="hljs-number">00</span>, <span class="hljs-number">00</span>)  <span class="hljs-comment"># May 28 2023 00:00:00</span>
end_timestamp = datetime(<span class="hljs-number">2023</span>, <span class="hljs-number">8</span>, <span class="hljs-number">20</span>, <span class="hljs-number">23</span>, <span class="hljs-number">59</span>, <span class="hljs-number">59</span>)  <span class="hljs-comment"># Aug 20 2023 23:59:59</span>

exporter = DataExporter()
<span class="hljs-keyword">if</span> exporter.generate_excelsheet(
        start_timestamp, end_timestamp, sheet_name=<span class="hljs-string">"Bookings Data.xlsx"</span>):
    send_email(<span class="hljs-string">"myemail@gmail.com"</span>, <span class="hljs-string">"Your Report"</span>, <span class="hljs-string">"Bookings Data.xlsx"</span>)
</code></pre>
<p>In the above code, we create two timestamp objects, <code>start_timestamp</code> and <code>end_timestamp</code>, to specify a time range. We have the start date set to May 28, 2023 at midnight and the end date set to August 20, 2023 just before midnight. </p>
<p>Next, we create an instance of the <code>DataExporter</code> class, which handles the data export and Excel sheet generation. The <code>generate_excelsheet</code> method of this instance is called with the previously defined timestamps to create a report related to bookings. </p>
<p>Finally, the code sends an email with the generated Excel sheet as an attachment using the <code>send_email</code> function.</p>
<h2 id="heading-how-to-schedule-the-application">How to Schedule the Application</h2>
<p>Next, our goal is to automate the report scheduling process. We aim to schedule report deliveries for two distinct scenarios: on every Monday for the previous week's data, and on the 1st day of every month for the previous month's information. </p>
<p>To schedule the execution, you will need to install the <code>schedule</code> library:</p>
<pre><code class="lang-bash">pip install schedule
</code></pre>
<p>Once the library is installed, here's how you can do automate the monthly and weekly reports:</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> schedule
<span class="hljs-keyword">from</span> exporter <span class="hljs-keyword">import</span> DataExporter
<span class="hljs-keyword">from</span> datetime <span class="hljs-keyword">import</span> datetime, timedelta
<span class="hljs-keyword">from</span> mailer <span class="hljs-keyword">import</span> send_email


<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">main</span>():</span>
    today = datetime.now()
    sheet_name = <span class="hljs-string">"Bookings Data.xlsx"</span>

    <span class="hljs-keyword">if</span> today.weekday() == <span class="hljs-number">0</span>:  <span class="hljs-comment"># Check if it's Monday (0 means Monday)</span>
        <span class="hljs-comment"># It's Monday, fetch data for the previous week (Monday to Sunday)</span>
        start_timestamp = (today - timedelta(days=<span class="hljs-number">7</span>)
                           ).replace(hour=<span class="hljs-number">0</span>, minute=<span class="hljs-number">0</span>, second=<span class="hljs-number">0</span>, microsecond=<span class="hljs-number">0</span>)
        end_timestamp = (today - timedelta(days=<span class="hljs-number">1</span>)
                         ).replace(hour=<span class="hljs-number">23</span>, minute=<span class="hljs-number">59</span>, second=<span class="hljs-number">59</span>, microsecond=<span class="hljs-number">0</span>)
        sheet_name = <span class="hljs-string">"Weekly Report.xlsx"</span>
    <span class="hljs-keyword">elif</span> today.day == <span class="hljs-number">29</span>:
        <span class="hljs-comment"># It's the 1st day of the month, fetch data for the last month</span>
        start_timestamp = (today.replace(day=<span class="hljs-number">1</span>) - timedelta(days=<span class="hljs-number">1</span>)
                           ).replace(day=<span class="hljs-number">1</span>, hour=<span class="hljs-number">0</span>, minute=<span class="hljs-number">0</span>, second=<span class="hljs-number">0</span>, microsecond=<span class="hljs-number">0</span>)
        end_timestamp = (today.replace(day=<span class="hljs-number">1</span>) - timedelta(days=<span class="hljs-number">1</span>)
                         ).replace(hour=<span class="hljs-number">23</span>, minute=<span class="hljs-number">59</span>, second=<span class="hljs-number">59</span>, microsecond=<span class="hljs-number">0</span>)
        sheet_name = <span class="hljs-string">"Monthly Report.xlsx"</span>

    exporter = DataExporter()
    exporter.generate_excelsheet(
        start_timestamp, end_timestamp, sheet_name)

    send_email(<span class="hljs-string">"youremail@gmail.com"</span>,
               <span class="hljs-string">"Your Report"</span>, sheet_name)


schedule.every().day.at(<span class="hljs-string">"00:00"</span>).do(main)

<span class="hljs-keyword">while</span> <span class="hljs-literal">True</span>:
    schedule.run_pending()
</code></pre>
<p>The above script uses the <code>schedule</code> library to run the <code>main</code> function daily at midnight. The <code>main</code> function calculates the timestamps for data extraction and Excel sheet generation. After generating the Excel sheet, the script sends it via email to a specified recipient.</p>
<p>If the script runs on a Monday, it sets up to generate a weekly report. It calculates the <code>start_timestamp</code> and <code>end_timestamp</code> for the previous week. The <code>start_timestamp</code> is set to the previous Monday at midnight (00:00:00), and the <code>end_timestamp</code> is set to the previous Sunday just before midnight (23:59:59). The Excel sheet is named "Weekly Report.xlsx."</p>
<p>On the 1st day of the month, the script shifts its focus to generating a monthly report. It calculates the <code>start_timestamp</code> and <code>end_timestamp</code> to encompass the entire previous month. The <code>start_timestamp</code> is set to the first day of the previous month at midnight (00:00:00), while the <code>end_timestamp</code> is set to the last day of the previous month just before midnight (23:59:59). The Excel sheet is named "Monthly Report.xlsx."</p>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>In this tutorial, you learned how you can leverage Python to automate generating a report and sending it to email recipients. I hope you found the tutorial helpful!</p>
<h3 id="heading-future-scope">Future Scope</h3>
<ul>
<li>You can add the email recipients in a database and fetch their list from there instead of hardcoding them in the code itself. This will make the application more configurable.</li>
<li>You can also use Cron Jobs to automate the execution of the script every day at midnight. In that case, you won't need the <code>schedule</code> library.</li>
</ul>
<p>Here's a link to the <a target="_blank" href="https://github.com/ashutoshkrris/report-automation">Github Code Repository</a>.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Add Numbers in Excel ]]>
                </title>
                <description>
                    <![CDATA[ Did you know you can write Python code in a spreadsheet? You'd be surprised how many different ways there are to do things in Excel. Below, I'll show you 9 ways to add two or more numbers. You can skip to a certain section if you'd like to see that ]]>
                </description>
                <link>https://www.freecodecamp.org/news/add-numbers-in-excel/</link>
                <guid isPermaLink="false">66b8ddc62755c964523f056c</guid>
                
                    <category>
                        <![CDATA[ excel ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Math ]]>
                    </category>
                
                    <category>
                        <![CDATA[ spreadsheets ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Eamonn Cottrell ]]>
                </dc:creator>
                <pubDate>Thu, 12 Oct 2023 21:02:58 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/10/add-numbers-thumb-2.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Did you know you can write Python code in a spreadsheet?</p>
<p>You'd be surprised how many different ways there are to do things in Excel. Below, I'll show you 9 ways to add two or more numbers. You can skip to a certain section if you'd like to see that method:</p>
<ol>
<li><a class="post-section-overview" href="#">Manual</a></li>
<li><a class="post-section-overview" href="#-1">References</a></li>
<li><a class="post-section-overview" href="#-2">SUM()</a></li>
<li><a class="post-section-overview" href="#-3">SUMIF()</a></li>
<li><a class="post-section-overview" href="#-4">SUBTOTAL()</a></li>
<li><a class="post-section-overview" href="#-5">AGGREGATE()</a></li>
<li><a class="post-section-overview" href="#-6">VBA</a></li>
<li><a class="post-section-overview" href="#-7">Python</a></li>
<li><a class="post-section-overview" href="#-8">Highlight</a></li>
</ol>
<h2 id="heading-video-walkthrough">Video Walkthrough</h2>
<p>If you prefer to watch me go through each of these in a demo workbook, here's a video for that:</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/xe5Ohlgizi8" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p>To write a formula or a function in Excel (which we'll be doing in the examples below), start out by simply typing an equals sign in a cell.</p>
<p><code>=</code></p>
<p>This triggers Excel to know that what follows will be a formula or a built-in function.</p>
<p><a id="manual"></a></p>
<h2 id="heading-manual">Manual</h2>
<p>This is simplest version of a formula in Excel. Start out with the equals sign, and then type in the numbers and operation you want to do. Just like a calculator:</p>
<p><code>=6+102</code></p>
<p>Pressing enter will result in <code>108</code> being listed in the cell</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/image-30.png" alt="Image" width="600" height="400" loading="lazy">
<em>screenshot of manual addition in Excel</em></p>
<p><a id="reference"></a></p>
<h2 id="heading-references">References</h2>
<p>The next step up in Excel is to start using cell references. Notice that on the top and on the left side of the main spreadsheet area, there are columns designated by letters and rows designated by numbers.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/rowscolumns.png" alt="Image" width="600" height="400" loading="lazy">
<em>screenshot of rows and columns</em></p>
<p>We can refer to specific cells using "A1" notation. Like a set of (x,y) coordinates on a graph, this simply means that by referring to C4, for instance, we are referring to the cell found in column C, row 4.</p>
<p>To add numbers using references, we start again with the equals sign and refer to the values in specific cells directly.</p>
<p>This has the added advantage of being dynamic. If a value is changed in one of the cells, the result of the sum automatically updates.</p>
<p><code>=SUM(A1+A3)</code> provides us with the value of the numbers in <code>A1</code> and <code>A3</code>.</p>
<p><a id="sum"></a></p>
<h2 id="heading-sum">SUM()</h2>
<p>The first two methods are examples of using formulas. We manually give Excel a series of instructions that it executes. </p>
<p>Excel also has built-in functions which we can use by starting with the equals sign and then referring to the function by name. Functions also take variables which we pass to them by using a set of parenthesis after the name of the function.</p>
<p>The <code>SUM()</code> function takes either a range or a comma-separated list of cell references. It then returns the sum of all the numbers in the range. </p>
<p>You can select a range by either clicking and dragging or by declaring one by typing in the A1 notation with a colon in between the top left cell and the bottom right cell of the range.</p>
<p><code>SUM(A5:A11)</code> adds all the numbers in cells <code>A5, A6, A7, A8, A9, A10, A11</code></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/image-31.png" alt="Image" width="600" height="400" loading="lazy">
<em>screenshot of the SUM() function</em></p>
<p><a id="sumif"></a></p>
<h2 id="heading-sumif">SUMIF()</h2>
<p>A more powerful version of <code>SUM()</code> is the <code>SUMIF()</code> function. This adds conditional logic. It needs at least two variables: a range and a condition. We could give it the same range as above and have a condition be that it only adds up numbers that are greater than zero.</p>
<p>A third, optional variable is a <code>sum_range</code>. This allows for us to match a condition in one range with the sum of values in another range.</p>
<p>In the example sheet, I have inserted checkboxes in column C. Checkboxes in Excel are <a target="_blank" href="https://youtu.be/hROvLovbl8E">a new feature</a>. This is the range that I'm checking for a condition. The condition is TRUE. Now I enter the range that I want to sum if the condition in the corresponding row of the first range is indeed TRUE.</p>
<p>When using a range and a sum_range separately like this, they do have to be of the same size or it will not behave as you want it to.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/image-32.png" alt="Image" width="600" height="400" loading="lazy">
<em>screenshot of SUMIF() function in Excel</em></p>
<p><a id="subtotal"></a></p>
<h2 id="heading-subtotal">SUBTOTAL()</h2>
<p>Ok, here's where things start to get interesting.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/butts.gif" alt="Image" width="600" height="400" loading="lazy"></p>
<p>The <code>SUBTOTAL()</code> function allows us to do a ton of different things. Ultimately, it returns a subtotal of a list or database. But inside of <code>SUBTOTAL()</code> there are other functions. The first argument that we give <code>SUBTOTAL()</code> is a number corresponding to one of these functions:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/image-33.png" alt="Image" width="600" height="400" loading="lazy">
<em>screenshot of functions within SUBOTAL from Microsoft Excel</em></p>
<p>Looking at the function list, we see that 9 or 109 both correspond to the <code>SUM()</code> function which we want to use. If we have hidden rows in our range that we don't want to include in the sum, we use 109 to ignore those – if not, simply 9.</p>
<p>So the function looks like this: <code>SUBTOTAL(9,B3:B12)</code>. This sums <code>B3:B12</code> even if one or more of those rows are hidden.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/image-34.png" alt="Image" width="600" height="400" loading="lazy">
<em>screenshot of SUBTOTAL in Excel</em></p>
<p><a id="aggregate"></a></p>
<h2 id="heading-aggregate">AGGREGATE()</h2>
<p>We can think of <code>AGGREGATE()</code> as a souped-up version of <code>SUBTOTAL()</code>. It works in the same way but has a lot more built-in functions (19 of them) and allows for detailed specificity on what values, if any, to ignore in the calculation.</p>
<p><code>AGGREGATE(function_num, options, ref1, [ref2], …)</code> is the full reference formula. Again, we pass it a number corresponding to one of the 19 built-in functions, then an optional argument for what type of values to ignore, followed by the reference array and an optional second reference array.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/image-35.png" alt="Image" width="600" height="400" loading="lazy">
<em>screenshot of options for Aggregate function from Microsoft Excel</em></p>
<p>For our example, we again use 9 as our function number, but we can use option 5 to explicitly exclude hidden rows:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/image-36.png" alt="Image" width="600" height="400" loading="lazy">
<em>screenshot of Aggregate function in Excel</em></p>
<p><a id="vba"></a></p>
<h2 id="heading-vba">VBA</h2>
<p>Now we're warmed up. Let's get overly complicated.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/complicated.gif" alt="Image" width="600" height="400" loading="lazy">
<em>gif of complicated nonsense</em></p>
<p>Visual Basic for Applications is Microsoft's baked-in programming language in Microsoft Office applications.</p>
<p>Open it up by selecting Visual Basic from the Developer tab. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/vba.png" alt="Image" width="600" height="400" loading="lazy">
<em>screenshot of VBA in Developer tab in Excel</em></p>
<p>If you don't see the developer tab, go to File - Options - Customize Ribbon and add it.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/developer-tab.png" alt="Image" width="600" height="400" loading="lazy">
<em>screenshot of Customizing Ribbon in Excel</em></p>
<p>Also, <code>Alt +11</code> is the keyboard shortcut to open up VBA.</p>
<p>Once here, we can write code to do all sorts of things. Our example isn't very practical since a function will do it quicker, but the following code will Sum the range <code>A1:A11</code>, put the result in <code>F11</code> and display a message pop-up with the result:</p>
<pre><code class="lang-vba">Sub AssignSumVariable()
   Dim result As Double
   'Assign the variable
   result = WorksheetFunction.Sum(Range("B1:B11"))
   'Show the result
   MsgBox "The total of the ranges is " &amp; result
   'Put the result in cell F9
  Range("F9") = result
End Sub
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/image-37.png" alt="Image" width="600" height="400" loading="lazy">
<em>screenshot of VBA in Excel</em></p>
<p><a id="python"></a></p>
<h2 id="heading-python">Python</h2>
<p>Yes, this is now ridiculous. But, it's good to know what Excel can do when you have more complicated tasks that require tools like VBA or Python. At the time of this writing, Python is available in Excel for people using the Beta Channel of Excel.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/overkill.gif" alt="Image" width="600" height="400" loading="lazy">
<em>gif of woman saying "seems like overkill"</em></p>
<p>You can check your eligibility and join Microsoft 365 Insider if you want to test out new features like this in the future.</p>
<p>Go to File - Account, and then select the 365 Insider channel button for more info.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/image-38.png" alt="Image" width="600" height="400" loading="lazy">
<em>screenshot of Microsoft 365 Insider options</em></p>
<p>Once Python is usable in Excel, you activate it by typing <code>=py</code> and then the <code>tab</code> key. This turns the cell into a Python command line.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/image-39.png" alt="Image" width="600" height="400" loading="lazy">
<em>screenshot of Python command line in Excel</em></p>
<p>From here, we can write Python code directly in the cell. The following code uses the custom xl() function for Python to use a range. We hold the range in the numbers variable and then using dot notation, we sum that range with the <code>numbers.sum()</code> line:</p>
<pre><code class="lang-python">numbers = xl(<span class="hljs-string">"'Sum➕'!$B$3:$B$12"</span>)
numbers.sum()
</code></pre>
<p>Now to execute the Python code, click <code>CTRL + ENTER</code>.</p>
<p>What we now see is that we've got a Python Series in the cell:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/image-40.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>In order to just display the answer, we can click the Python Output selector just to the left of the formula bar and select <code>Excel Value</code>:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/python-object.png" alt="Image" width="600" height="400" loading="lazy">
<em>screenshot of Python Output in Excel</em></p>
<p>Now, our cell is updated with the correct value.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/image-42.png" alt="Image" width="600" height="400" loading="lazy">
<em>screenshot of cells in Excel</em></p>
<p>The real value of Python in Excel comes with manipulating dataframes using built-in libraries like Matplotlib, NumPy, or Pandas.</p>
<p>Okay, take a breath, we'll finish with something simple and easy...👇</p>
<p><a id="highlight"></a></p>
<h2 id="heading-highlight">Highlight</h2>
<p>Bonus time. If you highlight cells in Excel by either clicking and dragging mouse over a range, or by <code>CTRL</code>+ <code>Left-Click</code> individual cells, some automatic calculations are visible in the bottom right of the window, including the Average, Count and Sum:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/highlight.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>If the sum isn't immediately visible, right clicking will pull up auto-calculations that you can toggle on and off:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/image-29.png" alt="Image" width="600" height="400" loading="lazy">
<em>screenshot of auto-calculation options in Excel</em></p>
<h2 id="heading-thanks-for-reading">Thanks for reading!</h2>
<p>Hope this is helpful for you!</p>
<p>Follow me on LinkedIn: <a target="_blank" href="https://www.linkedin.com/in/eamonncottrell/">https://www.linkedin.com/in/eamonncottrell/</a></p>
<p>And YouTube: <a target="_blank" href="https://www.youtube.com/@eamonncottrell">https://www.youtube.com/@eamonncottrell</a></p>
<p>Have a great one! 👋</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Create Data Validation Rules in Excel ]]>
                </title>
                <description>
                    <![CDATA[ By Faith Oyama Data validation is a feature in Excel used in restricting data entry in specific cells. It can also prompt the user to enter valid data into the cells based on the rules and restrictions provided by the creator of the Excel worksheet. ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/create-data-validation-rules-excel/</link>
                <guid isPermaLink="false">66d45edd4a7504b7409c33d5</guid>
                
                    <category>
                        <![CDATA[ data ]]>
                    </category>
                
                    <category>
                        <![CDATA[ excel ]]>
                    </category>
                
                    <category>
                        <![CDATA[ spreadsheets ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Fri, 26 May 2023 00:07:47 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/05/pexels-pixabay-262438.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Faith Oyama</p>
<p>Data validation is a feature in Excel used in restricting data entry in specific cells. It can also prompt the user to enter valid data into the cells based on the rules and restrictions provided by the creator of the Excel worksheet. </p>
<p>When setting up a workbook, you might want to make sure users input a specific type of data. For example, you might want to allow only dates, numbers, or letters in a specific range to be imputed in a cell. This is crucial if you want to eliminate mistakes as much as possible in your data.</p>
<h2 id="heading-types-of-data-validation-rules-in-excel">Types of Data Validation Rules in Excel</h2>
<p>Here are a few data validation rules you can set up in Excel:</p>
<ul>
<li>Only allow text or numeric values in a cell.</li>
<li>Only allow numbers within a specific range.</li>
<li>Display a warning message when a user inputs the wrong data.</li>
<li>Only allow dates and times outside a given range.</li>
<li>Validation rule based on criteria from another cell.</li>
</ul>
<h2 id="heading-steps-to-create-data-validation-rules-in-excel">Steps to Create Data Validation Rules in Excel.</h2>
<p>To create a data validation rule in Excel, do the following:</p>
<p>First, select the row, column, or specific cell you want to apply a data validation rule to.</p>
<p>Then open the data pane and click on the data validation. Alternatively, you can go directly to the data validation dialogue box by pressing the following keys on your keyboard separately. ALT &gt; D &gt; L. Do not hold the keys together, press the keys separately and you will be taken to the dialogue box as well.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/04/data-menu.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Create the data validation based on what data you want to be supplied in the cell or row.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/04/data-validation.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>You can supply the following validation criteria:</p>
<p><strong>Allow</strong>: Make a rule based on the type of data you want to allow. You can choose one from the drop-down menu. You can uncheck the “Ignore blank” button if you do not want blank spaces.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/04/select-whole-number.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><strong>Data</strong>: From the drop-down menu you can choose the criteria and also input the minimum and maximum values you want the user to input. </p>
<p>With the validation criteria set, click OK to close the window or click on the Input Message or Error Alert tab to give the user more information on the data validation rule.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/04/select-between.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><strong>Input message</strong>: While this is optional, you can input a message to be displayed when a user clicks on a cell that has a data validation rule defined on it.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/04/input-message.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Next, give your input message a title, and under the input message, make sure the message you provide is clear to the user. Click on OK to close the dialogue box or navigate to the Error Alert tab.</p>
<p>Then display an error message. This is optional, but it is good practice to display an error message to users when they enter data that is outside the validation rule you set.</p>
<p>There are three types of error alerts:</p>
<ol>
<li><strong>Stop:</strong> This is the default and is very strict, as it stops users from entering  invalid data. You can only click on “Retry” or “Cancel”</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/04/enter-a-valid-number-popup.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ol start="2">
<li><strong>Warning:</strong> This will only warn the user but is not as strict as the stop warning. A user can ignore the message by clicking “YES” the invalid data will be inputted.</li>
</ol>
<p>Here’s an example of the warning message a user will get:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/04/continue-no.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ol start="3">
<li><strong>Information:</strong> This is a permissive type of error alert as it only informs the user about invalid data inputted.</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/04/continue-yes.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>If the user clicks OK, the invalid gets inserted into the worksheet. If the user clicks on Cancel, the data gets deleted.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/04/error-alert-stop.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Give a title to the error alert and also provide a message for your users to see. When you’re done, click on OK, and your data validation rule has been set.</p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>Data validation in Excel is one powerful feature you should utilize when creating an Excel spreadsheet.</p>
<p>You can use the data validation feature in Excel to make rules that will ensure the data inputted meets certain criteria or follows predefined rules. Setting a data validation rule helps to maintain data accuracy, consistency, and integrity within your Excel worksheet.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Microsoft Excel – How to Use Data Validation and Conditional Formatting to Prevent Errors ]]>
                </title>
                <description>
                    <![CDATA[ I've been using Microsoft Excel and Google Sheets in my business for over a decade. And as I've learned better ways to clean and validate data, it's increased productivity, decreased human errors, and generally caused a lot of joy! 🥳 In this article... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/excel-use-data-validation-and-conditional-formatting-to-prevent-errors/</link>
                <guid isPermaLink="false">66b8dde4d68a0821bf8c474a</guid>
                
                    <category>
                        <![CDATA[ error ]]>
                    </category>
                
                    <category>
                        <![CDATA[ excel ]]>
                    </category>
                
                    <category>
                        <![CDATA[ spreadsheets ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Eamonn Cottrell ]]>
                </dc:creator>
                <pubDate>Mon, 06 Mar 2023 16:41:05 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/03/fcc.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>I've been using Microsoft Excel and Google Sheets in my business for over a decade. And as I've learned better ways to clean and validate data, it's increased productivity, decreased human errors, and generally caused a lot of joy! 🥳</p>
<p>In this article, we'll look at two ways to validate and/or apply conditional formatting to a sample order form to prevent errors and speed up fulfillment.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/no-error.gif" alt="Image" width="600" height="400" loading="lazy">
<em>gif of man saying, "there is no room for error"</em></p>
<p>You can find the Excel sheet we're using for this tutorial <a target="_blank" href="https://onedrive.live.com/edit.aspx?resid=FE6EDAF51E9AF322!1141&amp;ithint=file%2Cxlsx&amp;authkey=!ANRcKMn_p25YVyo">here</a>. </p>
<p>You may download a local copy to tinker with by selecting <code>File, Save As, Download a Copy</code>:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/image-21.png" alt="Image" width="600" height="400" loading="lazy">
<em>Download a copy of Excel Workbook</em></p>
<p>You can find a Google Sheets version of the same thing <a target="_blank" href="https://docs.google.com/spreadsheets/d/1gnacOaU_TCX_I7wGxHWWriyej4kI7t9AzM_nLybv9Cs/edit?usp=sharing">here</a>.</p>
<p>You may download or make a copy online by selecting <code>File, Download</code> or <code>File, Make a copy</code>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/image-22.png" alt="Image" width="600" height="400" loading="lazy">
<em>Download or make a copy of Google Sheet</em></p>
<p>I'll discuss the Excel version from here on, making reference when something differs in Google Sheets.</p>
<h2 id="heading-video-walkthrough">Video Walkthrough</h2>
<p>Oh, and here's an enjoyable video walkthrough should you feel so inclined. 😁😁</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/vMyBjyHGQ-U" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<h2 id="heading-setup">Setup</h2>
<p>I've created a three column order form where a store may inventory their product and enter an amount to order. The third column is used by the warehouse to enter how many were actually delivered. This is a real world setup that we'll use in simplified form for this tutorial.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/image-23.png" alt="Image" width="600" height="400" loading="lazy">
<em>Sample order form in Excel</em></p>
<p>It can be difficult for fulfillment if there are zeros entered into the order column. Instead of allowing this, we'll use a couple tools to show how to control values in a cell. No matter how clear the directions are, someone will always forget and enter a zero.</p>
<h2 id="heading-conditional-formatting">Conditional Formatting</h2>
<p>By applying conditional formatting, we can effectively white-out the cells that contain zeros (or any negative values).</p>
<p>From the Home Ribbon in Excel and the Format menu in Google Sheets, select <code>Conditional Formatting</code>. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/conditional-on-classic-ribbon.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>If you don't see the conditional formatting as an option, it'll be over in the styles dropdown or in the far right in a three-dotted dropdown, depending on whether you've got the classic or the new style of ribbon displayed.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/differnt-ribbon.png" alt="Image" width="600" height="400" loading="lazy">
<em>Conditional formatting menu in Excel Ribbons</em></p>
<p>If you want to change your ribbon's layout, select this dropdown arrow at the far right of the ribbon:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/ribbon.png" alt="Image" width="600" height="400" loading="lazy">
<em>Change Excel Ribbon layout</em></p>
<p>Once you're in the conditional format menu, click <code>Manage Rules</code>. This will let you specify the formatting depending on a ton of options. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/manage-rules.png" alt="Image" width="600" height="400" loading="lazy">
<em>Manage conditional formatting rules in Excel</em></p>
<p>This is where Microsoft Excel does have a leg up on Google Sheets. Excel has more options laid out in a more intuitive way. You can do the same things in each program, but Excel has organized theirs a little better in my opinion.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/image-26.png" alt="Image" width="600" height="400" loading="lazy">
<em>Conditional formatting menu organization in Excel</em></p>
<p>We are going to select the Order column as our range and then highlight cells with cell values of less than or equals to zero. </p>
<p>At other times, you'll be using conditional formatting to make data visualization using colors and color scales, but in our case, we want to blot out the zero value. </p>
<p>To do this, I've simply selected a white fill color and a white text color. 🤔</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/image-25.png" alt="Image" width="600" height="400" loading="lazy">
<em>Conditional formatting menu</em></p>
<p>And now, voilà! If a zero amount is entered, it will simply white out to not distract from the fulfillment center:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/zero.png" alt="Image" width="600" height="400" loading="lazy">
<em>Zero value entered and conditional formatting applied</em></p>
<h2 id="heading-data-validation">Data Validation</h2>
<p>The second option at our disposal is data validation. You can find this on the data tab in the ribbon, and if you're not seeing it, you can find it by exploring the same ribbon options I detailed above.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/validation-1.png" alt="Image" width="600" height="400" loading="lazy">
<em>Data validation menu in ribbon</em></p>
<p>This will give us a host of options to select to validate the data going into a specified range. There are many options to choose from for our data.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/image-30.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>In our case, we want to make sure they are whole numbers greater than zero. Sort of the opposite of the conditional formatting we did above.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/image-29.png" alt="Image" width="600" height="400" loading="lazy">
<em>Data validation</em></p>
<p>Another nice Excel feature that's missing at the time of this writing in Google Sheets is the ability to put an Input Message into the data validation.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/image-31.png" alt="Image" width="600" height="400" loading="lazy">
<em>Input message in data validation</em></p>
<p>Now, whenever you are on cell in the data validation range, a friendly box will pop up with directions reminding you to not order a zero amount. 😀</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/image-32.png" alt="Image" width="600" height="400" loading="lazy">
<em>Example of input text in spreadsheet</em></p>
<p>Data validation in Excel defaults to blocking any input that doesn't adhere to the defined conditions. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/image-33.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>So, you'll receive an ugly pop up preventing you from entering a zero.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/image-34.png" alt="Image" width="600" height="400" loading="lazy">
<em>data validation warning</em></p>
<p>We can improve upon this by setting a custom message here too, though. And we can select whether to block it outright or to allow a zero to be entered after the warning pops up. Effectively allowing the warning to be ignored in the event that there's a reason to do this.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/image-35.png" alt="Image" width="600" height="400" loading="lazy">
<em>data validation custom warning message</em></p>
<p>And finally, we can couple any of these options with our conditional formatting so that if we do only warn against the entry, we still blot it out with the white text and white fill color.</p>
<p>The accompanying <a target="_blank" href="https://onedrive.live.com/edit.aspx?resid=FE6EDAF51E9AF322!1141&amp;ithint=file%2cxlsx&amp;authkey=!ANRcKMn_p25YVyo">Excel Sheet</a> and <a target="_blank" href="https://docs.google.com/spreadsheets/d/1gnacOaU_TCX_I7wGxHWWriyej4kI7t9AzM_nLybv9Cs/edit#gid=1341856047">Google Sheet</a> contain four columns of each of the above examples for you to see in action.</p>
<p>I hope this has been helpful for you! </p>
<p>Please come see my <a target="_blank" href="https://www.youtube.com/@eamonncottrell?sub_confirmation=1">video tutorials on YouTube</a>. I'd appreciate a like and subscribe as I'm growing my tech education channel there!</p>
<p>Have a great one!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Automate Excel Tasks with Python ]]>
                </title>
                <description>
                    <![CDATA[ Excel is a surprisingly common tool for data analysis. Data analysts can readily modify, examine, and display huge amounts of data with Excel, which makes it simpler to gain insights and make wise choices. Excel's versatility lets users carry out a v... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/automate-excel-tasks-with-python/</link>
                <guid isPermaLink="false">66d4608b33b83c4378a5181e</guid>
                
                    <category>
                        <![CDATA[ automation ]]>
                    </category>
                
                    <category>
                        <![CDATA[ excel ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Python ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Jeremiah Oluseye ]]>
                </dc:creator>
                <pubDate>Wed, 01 Mar 2023 19:04:17 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/03/FreecodeCamp.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Excel is a surprisingly common tool for data analysis.</p>
<p>Data analysts can readily modify, examine, and display huge amounts of data with Excel, which makes it simpler to gain insights and make wise choices.</p>
<p>Excel's versatility lets users carry out a variety of data analysis activities, from straightforward math operations to intricate statistical analysis. Also, Excel offers automation through the use of third-party programs like Python or the built-in programming language VBA.</p>
<p>Excel is frequently used for data analysis across a range of industries, including banking, healthcare, and marketing, thanks to its versatility and usability.</p>
<p>But as a data analyst, you might often find yourself repeating mundane tasks on a daily basis when working with Excel.</p>
<p>These tasks may include copying and pasting data, formatting cells, and creating charts, among others. Over time, this can become monotonous and time-consuming, leaving you with less time to focus on more important aspects of data analysis, such as identifying trends, outliers, and insights.</p>
<p>This is why automating Excel using Python can be a game-changer, helping you streamline your workflows and free up time for more meaningful analysis.</p>
<p>In this tutorial, I'll show you some helpful ways to create, update, and analyze Excel spreadsheets using Python programming. Let's dive in.</p>
<h2 id="heading-how-to-merge-two-separate-spreadsheets-with-python">How to Merge Two Separate Spreadsheets with Python</h2>
<p>Data analysts often have to work on many spreadsheets, which can become hectic when you have to merge those files together.</p>
<p>The code below helps you merge two separate files together.</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd

<span class="hljs-comment"># Read in the two Excel files</span>

file1 = pd.read_excel(<span class="hljs-string">'file1.xlsx'</span>)file2 = pd.read_excel(<span class="hljs-string">'file2.xlsx'</span>)

<span class="hljs-comment"># Merge the two files using the concat() method</span>
merged_file = pd.concat([file1, file2], ignore_index=<span class="hljs-literal">True</span>)

<span class="hljs-comment"># Write the merged file to a new Excel file</span>
merged_file.to_excel(<span class="hljs-string">'merged_file.xlsx'</span>, index=<span class="hljs-literal">False</span>)
</code></pre>
<p>In this code, we first import the Pandas library, which we'll use to read in and manipulate the Excel files.</p>
<p>We then use the <code>read_excel()</code> method to read in both <code>file1.xlsx</code> and <code>file2.xlsx</code>. Next, we use the <code>concat()</code> method to merge the two files together. The <code>ignore_index=True</code> argument ensures that the index values from both files are reset, so we don't end up with duplicate index values in the merged file.</p>
<p>Finally, we use the <code>to_excel()</code> method to write the merged file to a new Excel file named <code>merged_file.xlsx</code>. We also set <code>index=False</code> to ensure that the index column is not included in the output file.</p>
<h2 id="heading-how-to-import-and-export-data-with-python">How to Import and Export Data with Python</h2>
<p>This task involves using Python libraries such as Pandas to read Excel files into a DataFrame object. You can then manipulate it and analyze it using Python.</p>
<p>You can also export data from Python back into an Excel file using the same libraries.</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd
<span class="hljs-comment"># Import Excel file</span>

df = pd.read_excel(<span class="hljs-string">'filename.xlsx'</span>, sheet_name=<span class="hljs-string">'Sheet1'</span>)

<span class="hljs-comment"># Export to Excel file</span>
df.to_excel(<span class="hljs-string">'new_filename.xlsx'</span>, index=<span class="hljs-literal">False</span>)
</code></pre>
<p>The given code imports the Pandas library and reads an Excel file named "filename.xlsx" from Sheet1 of the workbook, storing the data in a Pandas dataframe named "df". The dataframe is then exported to a new Excel file named "new_filename.xlsx" using the "to_excel" method. The "index=False" parameter is used to exclude row indexing in the output file.</p>
<p>Essentially, the code copies the contents of the original Excel file to a new file using Pandas.</p>
<h2 id="heading-how-to-clean-and-transform-data-using-python">How to Clean and Transform Data using Python</h2>
<p>This task involves using Python libraries such as Pandas to clean and transform data in Excel.</p>
<p>This may include removing duplicates, filtering data based on specific criteria, and performing calculations on the data.</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd

<span class="hljs-comment"># Remove duplicates</span>
df = df.drop_duplicates()

<span class="hljs-comment"># Filter data</span>
df = df[df[<span class="hljs-string">'column_name'</span>] &gt; <span class="hljs-number">10</span>]

<span class="hljs-comment"># Perform calculations</span>
df[<span class="hljs-string">'new_column'</span>] = df[<span class="hljs-string">'column1'</span>] + df[<span class="hljs-string">'column2'</span>]
</code></pre>
<p>The code snippet above performs data cleaning and manipulation tasks on a Pandas dataframe named 'df' using the Pandas library.</p>
<p>Firstly, it removes duplicate rows from 'df' using the "drop_duplicates" method. Secondly, it filters the 'df' dataframe by selecting rows where the value in the 'column_name' column is greater than 10 and assigns the filtered result to a new dataframe called 'data_df'.</p>
<p>Lastly, a new column named 'new_column' is added to 'df' which contains the sum of values from 'column1' and 'column2'.</p>
<p>Overall, the code effectively cleans and manipulates the data by removing duplicates, filtering specific rows, and adding a new calculated column to the original dataframe.</p>
<h2 id="heading-how-to-perform-data-analysis-with-python">How to Perform Data Analysis with Python</h2>
<p>This task involves using Python libraries such as Pandas and NumPy to perform data analysis on Excel data.</p>
<p>This may include calculating summary statistics, such as mean and standard deviation, or creating custom reports by grouping data based on specific criteria.</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np

<span class="hljs-comment"># Calculate summary statistics</span>
df.describe()
<span class="hljs-comment"># Create custom reports</span>
df.pivot_table(values=<span class="hljs-string">'column_name'</span>, index=<span class="hljs-string">'category_name'</span>, columns=<span class="hljs-string">'date'</span>)
</code></pre>
<p>The code utilizes the Pandas and NumPy libraries and performs data analysis and reporting tasks on a Pandas dataframe named "df".</p>
<p>Firstly, it calculates summary statistics for the numerical data in the dataframe using the "describe" method. This method generates valuable insights on the data's distribution, central tendency, and dispersion.</p>
<p>Secondly, the code uses the "pivot_table" method to create customized reports from the dataframe. This method summarizes and aggregates the data in the dataframe and can produce tables in various formats.</p>
<p>In this code, it generates a new dataframe where the 'column_name' values are grouped by the 'category_name' and 'date' columns.</p>
<p>Overall, the code performs statistical analysis and reporting tasks on the dataframe to gain insights from the data.</p>
<h2 id="heading-how-to-create-charts-with-python">How to Create Charts with Python</h2>
<p>This task involves using Python libraries such as matplotlib or seaborn to create charts and graphs from Excel data.</p>
<p>You can customize these charts to display specific data and format them to meet specific requirements.</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd
<span class="hljs-keyword">import</span> matplotlib.pyplot <span class="hljs-keyword">as</span> plt
<span class="hljs-comment"># Create a bar chart</span>
df.plot(kind=<span class="hljs-string">'bar'</span>, x=<span class="hljs-string">'category_name'</span>, y=<span class="hljs-string">'sales'</span>)
plt.show()
<span class="hljs-comment"># Create a scatter plot</span>
df.plot(kind=<span class="hljs-string">'scatter'</span>, x=<span class="hljs-string">'column1'</span>, y=<span class="hljs-string">'column2'</span>)plt.show()
</code></pre>
<p>The code imports two libraries, Pandas and matplotlib.pyplot using the aliases 'pd' and 'plt', respectively.</p>
<p>The Pandas "plot" method is then used to create two types of plots. The first type of plot is a bar chart that shows the relationship between the 'category_name' and 'sales' columns in the "df" dataframe.</p>
<p>The second type of plot is a scatter plot that shows the relationship between the 'column1' and 'column2' columns in the same dataframe. The code uses the parameters "kind='bar'" for the bar chart and "kind='scatter'" for the scatter plot to create the respective plots.</p>
<p>Lastly, the "show" method is called to display the plots on the screen. In summary, the code utilizes Pandas and matplotlib to create a bar chart and a scatter plot to visualize the data in the "df" dataframe.</p>
<h2 id="heading-how-to-do-data-visualization-in-python">How to Do Data Visualization in Python</h2>
<p>This task involves using Python libraries such as Plotly and bokeh to create interactive data visualizations from Excel data.</p>
<p>These visualizations allow users to explore data in new ways, such as by zooming in on specific data points or filtering data based on specific criteria.</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd
<span class="hljs-keyword">import</span> plotly.express <span class="hljs-keyword">as</span> px
<span class="hljs-comment"># Create a heatmap</span>
fig = px.imshow(df.corr())
fig.show()
<span class="hljs-comment"># Create a line chart</span>
fig = px.line(df, x=<span class="hljs-string">'date'</span>, y=<span class="hljs-string">'sales'</span>, color=<span class="hljs-string">'category'</span>)
fig.show()
</code></pre>
<p>The code uses the Pandas and plotly.express libraries to create two types of visualizations. First, a heatmap plot is created using plotly.express's "imshow" method that visualizes the correlation between columns in the "df" dataframe.</p>
<p>Second, a line chart is created using plotly.express's "line" method that displays the relationship between the 'date' and 'sales' columns while differentiating between categories based on the 'category' column of the dataframe. Both plots are displayed using the "show" method.</p>
<h2 id="heading-how-to-automate-report-generation-with-python">How to Automate Report Generation with Python</h2>
<p>This task involves using Python scripts to automate the process of generating reports from Excel data.</p>
<p>You can set up these scripts to run on a regular schedule, such as daily or weekly. They can also automatically update as new data becomes available.</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd
<span class="hljs-comment"># Create daily report</span>
df_daily = df[df[<span class="hljs-string">'date'</span>] == <span class="hljs-string">'2022-01-01'</span>]
df_daily.to_excel(<span class="hljs-string">'daily_report.xlsx'</span>, index=<span class="hljs-literal">False</span>)
<span class="hljs-comment"># Create weekly report</span>
df_weekly = df.groupby(<span class="hljs-string">'category'</span>).sum()
df_weekly.to_excel(<span class="hljs-string">'weekly_report.xlsx'</span>, index=<span class="hljs-literal">False</span>)
</code></pre>
<p>The code creates a daily report by creating a new dataframe "df_daily" that includes only the rows where the 'date' column equals '2022-01-01'. This is achieved by using Pandas' boolean indexing feature.</p>
<p>Afterward, the "to_excel" method is used to export the filtered data to an Excel file named "daily_report.xlsx", without including the index column.</p>
<p>Next, the code creates a weekly report by grouping the "df" dataframe by the 'category' column and summing the values of all other columns. This is accomplished using the Pandas "groupby" and "sum" methods.</p>
<p>The result is saved in a new dataframe named "df_weekly". Lastly, the "to_excel" method is used to export the aggregated data to an Excel file named "weekly_report.xlsx", without including the index column.</p>
<p>In summary, the code creates two reports using the Pandas library. The first report is a daily report that includes only data from a specific date, and the second report is a weekly report that aggregates data by category. Both reports are exported to Excel files using the "to_excel" method.</p>
<h2 id="heading-how-to-automate-repetitive-tasks-with-macros-and-scripts-in-python">How to Automate Repetitive Tasks with Macros and Scripts in Python</h2>
<p>This task involves using Python to automate repetitive tasks in Excel, such as data entry or formatting. You can do this by creating macros or scripts that can execute automatically, or by using Python to interact with the Excel application directly.</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> win32com.client <span class="hljs-keyword">as</span> win32
<span class="hljs-comment"># Open Excel file</span>
excel = win32.gencache.EnsureDispatch(<span class="hljs-string">'Excel.Application'</span>)
workbook = excel.Workbooks.Open(<span class="hljs-string">r'filename.xlsx'</span>)
<span class="hljs-comment"># Run macro</span>
excel.Application.Run(<span class="hljs-string">'macro_name'</span>)
<span class="hljs-comment"># Save and close Excel</span>
 fileworkbook.Save()workbook.Close()excel.Quit()
</code></pre>
<p>The code uses the win32com.client module to interact with Microsoft Excel via the Windows API.</p>
<p>First, an instance of the Excel application is opened using the <code>EnsureDispatch()</code> method, and the specified Excel file is opened using the <code>Workbooks.Open()</code> method.</p>
<p>Next, a macro is executed using the <code>Application.Run()</code> method, passing the name of the macro as an argument.</p>
<p>Finally, the changes made to the Excel file are saved using the <code>Save()</code> method, the workbook is closed using the <code>Close()</code> method, and the Excel application is terminated using the <code>Quit()</code> method</p>
<h2 id="heading-how-to-scrape-data-with-python">How to Scrape Data with Python</h2>
<p>This task involves using Python libraries such as requests and Beautiful Soup to scrape data from web pages or other sources and import it into Excel.</p>
<p>You can then analyze and manipulate this data using Python libraries such as Pandas.</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">from</span> bs4 <span class="hljs-keyword">import</span> BeautifulSoup
<span class="hljs-comment"># Scrape data from web page</span>
url = <span class="hljs-string">'https://www.website.com/data'</span>
response = requests.get(url)
soup = BeautifulSoup(response.text, <span class="hljs-string">'html.parser'</span>)
table = soup.find(<span class="hljs-string">'table'</span>)
df = pd.read_html(str(table))[<span class="hljs-number">0</span>]
<span class="hljs-comment"># Export to Excel file</span>
df.to_excel(<span class="hljs-string">'scraped_data.xlsx'</span>, index=<span class="hljs-literal">False</span>)
</code></pre>
<p>This code uses the requests library to send an HTTP GET request to the URL '<a target="_blank" href="https://www.example.com/">https://www.example.com</a>'. It then uses the BeautifulSoup library to parse the HTML content of the response into a BeautifulSoup object named 'soup'.</p>
<p>You can then use BeautifulSoup methods such as <code>find_all()</code> to extract specific data from the HTML:</p>
<p><code>links = []for link in soup.find_all('a'): href = link.get('href') links.append(href)</code></p>
<p>This code finds all the anchor tags in the HTML and extracts the value of the 'href' attribute for each one, adding them to a list named 'links'.</p>
<h2 id="heading-how-to-use-python-to-integrate-excel-with-other-applications">How to Use Python to Integrate Excel with Other Applications</h2>
<p>This task involves using Python to integrate Excel with other applications, such as databases or web services.</p>
<p>You can do this using Python libraries such as pyodbc to connect to databases or by using APIs to connect to web services. This allows for seamless data transfer and analysis between different applications.</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd
<span class="hljs-keyword">import</span> pyodbc
<span class="hljs-comment"># Connect to database</span>
cnxn = pyodbc.connect(<span class="hljs-string">'DRIVER={SQL Server};SERVER=server_name;DATABASE=db_name;UID=user_id;PWD=password'</span>)
<span class="hljs-comment"># Read data from database</span>
query = <span class="hljs-string">'SELECT * FROM table_name'</span>
df = pd.read_sql(query, cnxn)
<span class="hljs-comment"># Export to Excel file</span>
df.to_excel(<span class="hljs-string">'database_data.xlsx'</span>, index=<span class="hljs-literal">False</span>)
</code></pre>
<p>The code establishes a connection to a SQL Server database using <code>pyodbc.connect()</code> method, where the driver, server name, database name, user ID, and password are provided as arguments.</p>
<p>Then, a SQL query is defined and executed to retrieve data from a table in the database using the <code>pd.read_sql()</code> method, where the SQL query and the connection object are provided as arguments. The retrieved data is then stored in a pandas DataFrame.</p>
<p>Finally, the data in the DataFrame is exported to an Excel file named "database_data.xlsx" using the <code>to_excel()</code> method, with the index column excluded from the export by setting the index parameter to False.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Python is a versatile language that you can use to automate many Excel tasks. You can also use various libraries such as Pandas, openpyxl, xlwings, and pyautogui to manipulate data, extract information, generate reports, and automate repetitive tasks.</p>
<p>Automation can save time and effort, reduce errors, and boost productivity. Python proficiency can be a valuable skill for any professional working with Excel, whether you're a data or financial analyst. By learning Python, you can elevate your work to new heights.</p>
<p>Let’s connect on <a target="_blank" href="https://twitter.com/Olujerry19">Twitter</a> and <a target="_blank" href="https://www.linkedin.com/in/jeremiah-oluseye-58457719a/">LinkedIn</a>. Thanks for reading!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Unhide a Row or Column in Excel – Or Unhide All Rows and Columns ]]>
                </title>
                <description>
                    <![CDATA[ If you’re working with a spreadsheet that contains sensitive or private data, then some rows and columns might be hidden. You might also need to hide unimportant information or data you don’t want others to see in your own spreadsheet.  In these case... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-unhide-a-row-or-column-in-excel-or-unhide-all-rows-and-columns/</link>
                <guid isPermaLink="false">66adf14e11a28b6eb378d2b8</guid>
                
                    <category>
                        <![CDATA[ excel ]]>
                    </category>
                
                    <category>
                        <![CDATA[ spreadsheets ]]>
                    </category>
                
                    <category>
                        <![CDATA[ VBA ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Kolade Chris ]]>
                </dc:creator>
                <pubDate>Thu, 23 Feb 2023 22:45:03 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/02/unhideExcel.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>If you’re working with a spreadsheet that contains sensitive or private data, then some rows and columns might be hidden. You might also need to hide unimportant information or data you don’t want others to see in your own spreadsheet. </p>
<p>In these cases, you might need to unhide those hidden rows and columns before you start updating the spreadsheet examine the data it contains.</p>
<p>In this article, you will learn how to unhide rows and columns in Excel. You will also learn how to unhide all rows and columns in case they are all hidden.</p>
<p>This tutorial is applicable to Excel 2007 to 2016, but it can also guide you through how to do it in other versions of Excel.</p>
<h2 id="heading-what-well-cover">What We'll Cover</h2>
<ul>
<li><a class="post-section-overview" href="#heading-how-to-find-hidden-rows-and-columns">How to Find Hidden Rows and Columns</a></li>
<li><a class="post-section-overview" href="#heading-how-to-unhide-a-column-in-excel">How to Unhide a Column in Excel</a></li>
<li><a class="post-section-overview" href="#heading-how-to-unhide-a-row-in-excel">How to Unhide a Row in Excel</a></li>
<li><a class="post-section-overview" href="#heading-how-to-unhide-all-hidden-rows-and-columns-in-the-home-tab">How to Unhide all Hidden Rows and Columns in the Home Tab</a></li>
<li><a class="post-section-overview" href="#heading-how-to-unhide-all-rows-and-columns-at-once-with-vba-macro">How to Unhide all Rows and Columns at Once with VBA Micro </a></li>
<li><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></li>
</ul>
<p>Before we dive into how to unhide rows and columns in Excel, let’s look at how to find hidden rows and columns.</p>
<h2 id="heading-how-to-find-hidden-rows-and-columns">How to Find Hidden Rows and Columns</h2>
<p>You can detect a hidden row or column by looking at the lines that separate each row and each column. If the lines are double or green, then it means there's a hidden row or column.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/Screenshot-2023-02-23-at-11.49.19.png" alt="Screenshot-2023-02-23-at-11.49.19" width="600" height="400" loading="lazy"></p>
<p>Also, taking a look at the spreadsheet, if there are missing letters for the columns or missing numbers in the rows, then it’s possible there are hidden rows and columns in the spreadsheet.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/Screenshot-2023-02-23-at-11.49.43.png" alt="Screenshot-2023-02-23-at-11.49.43" width="600" height="400" loading="lazy"> </p>
<h2 id="heading-how-to-unhide-a-column-in-excel">How to Unhide a Column in Excel</h2>
<p>You can unhide a certain column by right-clicking on the double line that indicates the hidden column and selecting “unhide”:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/Screenshot-2023-02-23-at-11.56.27.png" alt="Screenshot-2023-02-23-at-11.56.27" width="600" height="400" loading="lazy"> </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/Screenshot-2023-02-23-at-13.04.02.png" alt="Screenshot-2023-02-23-at-13.04.02" width="600" height="400" loading="lazy"></p>
<h2 id="heading-how-to-unhide-a-row-in-excel">How to Unhide a Row in Excel</h2>
<p>If you want to unhide a row, right-click on the double line indicated in green (or if possible, another color based on the user settings), then select “unhide”:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/Screenshot-2023-02-23-at-12.01.11.png" alt="Screenshot-2023-02-23-at-12.01.11" width="600" height="400" loading="lazy"></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/Screenshot-2023-02-23-at-13.08.06.png" alt="Screenshot-2023-02-23-at-13.08.06" width="600" height="400" loading="lazy"> </p>
<h2 id="heading-how-to-unhide-all-hidden-rows-and-columns-in-the-home-tab">How to Unhide all Hidden Rows and Columns in the Home Tab</h2>
<p>To unhide all rows, select all rows and columns by pressing CTRL + A, go to the <code>Home</code> tab, locate cells, and click the arrow on "Format":</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/Screenshot-2023-02-23-at-12.07.16.png" alt="Screenshot-2023-02-23-at-12.07.16" width="600" height="400" loading="lazy"></p>
<p>Under visibility, hover on “Hide and Unhide”, then select “Unhide Rows”:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/Screenshot-2023-02-23-at-12.08.14.png" alt="Screenshot-2023-02-23-at-12.08.14" width="600" height="400" loading="lazy"></p>
<p>To unhide all hidden columns, you have to follow the same process, but this time around, you have to select “Unhide Columns”.</p>
<h2 id="heading-how-to-unhide-all-rows-and-columns-at-once-with-vba-macro">How to Unhide all Rows and Columns at Once with VBA Macro</h2>
<p>If you’re dealing with a large spreadsheet, the processes we just discussed might be tedious for you. </p>
<p>Instead of unhiding for the rows and columns one by one or unhiding rows and unhiding columns, you can run some VBA (Visual Basic for Applications) code to do it.</p>
<p>Here’s how to run VBA code in Excel:</p>
<p>Press ALT + F11 (or Option + F11 on Mac) to open the VBE (Visual Basic Editor):</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/Screenshot-2023-02-23-at-12.31.01.png" alt="Screenshot-2023-02-23-at-12.31.01" width="600" height="400" loading="lazy"></p>
<p>Right-click on your current workbook, hover on “Insert” and select “Module”:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/Screenshot-2023-02-23-at-12.32.53.png" alt="Screenshot-2023-02-23-at-12.32.53" width="600" height="400" loading="lazy"></p>
<p>Paste this code into the editor:</p>
<pre><code class="lang-bas">Sub UnhideAllRowsAndColumns()
  Cells.EntireColumn.Hidden = False
  Cells.EntireRow.Hidden = False
End Sub
</code></pre>
<p>Close the dialogue and go back to your worksheet. </p>
<p>Next, you need to run the VBA Micro. Press ALT + F8 and you’ll see something like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/Screenshot-2023-02-23-at-12.38.39.png" alt="Screenshot-2023-02-23-at-12.38.39" width="600" height="400" loading="lazy"></p>
<p>Expand it and click “Run”:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/Screenshot-2023-02-23-at-12.40.04.png" alt="Screenshot-2023-02-23-at-12.40.04" width="600" height="400" loading="lazy"></p>
<p>Every row and column should now show up:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/Screenshot-2023-02-23-at-13.03.28.png" alt="Screenshot-2023-02-23-at-13.03.28" width="600" height="400" loading="lazy"> </p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>This article showed you how to unhide a row or column in Excel. </p>
<p>The examples we looked at showed you how to unhide individual rows and columns, unhide all columns, and unhide all rows. </p>
<p>We also looked at how you can unhide rows and columns altogether with Excel VBE (Visual Basic Editor).</p>
<p>If you find this article helpful, share it with your friends and family.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ LOOKUP Functions in Google Sheets and Excel – VLOOKUP, XLOOKUP, and More ]]>
                </title>
                <description>
                    <![CDATA[ There are several ways to lookup data in a spreadsheet. If you're building a dashboard, you'll find this very useful.  The =XLOOKUP() function is my new favorite way to lookup data. It's discussed in the last section 👇. We'll look at four of the bui... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/lookup-functions-in-excel-google-sheets/</link>
                <guid isPermaLink="false">66b8de1b0cedc1f2a4f70681</guid>
                
                    <category>
                        <![CDATA[ excel ]]>
                    </category>
                
                    <category>
                        <![CDATA[ google sheets ]]>
                    </category>
                
                    <category>
                        <![CDATA[ spreadsheets ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Eamonn Cottrell ]]>
                </dc:creator>
                <pubDate>Tue, 07 Feb 2023 20:47:26 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/02/lookupFCC.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>There are several ways to lookup data in a spreadsheet. If you're building a dashboard, you'll find this very useful. </p>
<p>The =XLOOKUP() function is my new favorite way to lookup data. It's discussed in the last section 👇.</p>
<p>We'll look at four of the built in lookup functions in both Excel and Google Sheets:</p>
<ol>
<li><code>=LOOKUP()</code></li>
<li><code>=VLOOKUP()</code></li>
<li><code>=HLOOKUP()</code></li>
<li><code>=XLOOKUP()</code></li>
</ol>
<p>Now, if you've spent any time in spreadsheets, you've probably heard mention of or are already using <code>=VLOOKUP()</code>. It is one of the most popular functions out there, but is also a bit mystifying if you don't use it on a regular basis.</p>
<p>🏆 I'll walkthrough each of these to give you a full understanding of how to use the functions properly. And I'll highlight my new favorite, <code>=XLOOKUP()</code>, that Microsoft released in 2019 and Google Sheets added in 2022.</p>
<p>☕ I've also built a coffee themed Google Sheet that you can open and follow along with. <a target="_blank" href="https://docs.google.com/spreadsheets/d/1rNAJKwGQzdq8F2zMrAwHMQvY_z3FlBs9BIy_4MIOXn4/edit?usp=sharing">Here it is.</a></p>
<p>📽️ And, I've got you covered...at the end of the article there's a video walkthrough too. 💥</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/igotyou.gif" alt="Image" width="600" height="400" loading="lazy">
<em>Gif of athlete pointing and saying, I Got You!</em></p>
<h2 id="heading-coffee-data">Coffee Data</h2>
<p>In our coffee data spreadsheet, I have made two sheets with the same data on it. One, the <code>coffee-data</code> tab, is for <code>LOOKUP</code> and <code>VLOOKUP</code>. The <code>horizontal-data</code> tab is for <code>HLOOKUP</code>.</p>
<p>Here's what the <code>coffee-data</code> tab looks like. There are columns for the coffee name, price, popularity, roast level and taste.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/image-40.png" alt="Image" width="600" height="400" loading="lazy">
<em>Coffee Data Spreadsheet Screenshot</em></p>
<p>Here's what the <code>horizontal-data</code> tab looks like. Same info, just transposed so we can walk through the <code>HLOOKUP</code> function in a bit. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/image-41.png" alt="Image" width="600" height="400" loading="lazy">
<em>Coffee Data Horizontal Spreadsheet Screenshot</em></p>
<p>And then we have our main tab, <code>lookup-functions</code>, where we'll examine the different functions below.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/image-42.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>If you haven't pulled up the Google Sheet yet, go ahead so you can follow along: <a target="_blank" href="https://docs.google.com/spreadsheets/d/1rNAJKwGQzdq8F2zMrAwHMQvY_z3FlBs9BIy_4MIOXn4/edit#gid=1137792422">https://docs.google.com/spreadsheets/d/1rNAJKwGQzdq8F2zMrAwHMQvY_z3FlBs9BIy_4MIOXn4/edit#gid=1137792422</a></p>
<p>Everything works the same in Excel, but it's very easy to share Google Sheets. You can make your own copy to work in by clicking File -&gt; Make a copy.</p>
<p>I've created several named ranges in this sheet to make it easier as we fill out the functions. You can examine those by clicking Data -&gt; Named ranges. I'll reference these in the function definitions below.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/named-ranges.png" alt="Image" width="600" height="400" loading="lazy">
<em>Screenshot of named ranges in Google Sheets</em></p>
<h2 id="heading-how-to-use-the-lookup-function">How to Use the LOOKUP Function</h2>
<p>No surprise here – <code>=LOOKUP()</code> lets you look up a value in your data. Same as everything else here.</p>
<p><strong>Here's our LOOKUP function to return the taste: <code>=LOOKUP(A2,coffees,taste)</code>.</strong> </p>
<p>We're using named ranges (coffees &amp; taste) which define the coffees column and the tasting notes column in our <code>coffee-data</code>.</p>
<p>If you pull up the sample Google Sheet, you'll see that we're giving LOOKUP three arguments: the <code>search_key</code>, <code>search_range|search_result_array</code>, and the optional <code>[result_range]</code>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/image-28.png" alt="Image" width="600" height="400" loading="lazy">
<em>Screenshot of Lookup function</em></p>
<p>The <code>search_key</code> is the thing we're searching for. In our example, it's the name of the coffee we want information about. All of the functions have a <code>search_key</code> argument.</p>
<p>The <code>search_range|search_result_array</code> is the range where <code>=LOOKUP()</code> needs to find the <code>search_key</code>. It can be used as both search and result ranges too.</p>
<p>Say you have search keys in your coffee column (A) and the result you want displayed is the taste column (E). If you specify A:E as the <code>search_range|search_result_array</code> then you'll get the tasting notes on whatever coffee you're searching for.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/col.png" alt="Image" width="600" height="400" loading="lazy">
<em>Screenshot of table of data</em></p>
<p>When you do this, the result range value will come from the <strong>last column (or row) in the range</strong>.</p>
<p>The alternative is to simply specify the <code>search_range</code> column on the coffee column and then enter another range for the <code>result_range</code>.</p>
<p>This is what I've done in our sample spreadsheet since I wanted to pull data from each of the columns about the coffee.</p>
<p>Shortcomings of <code>=LOOKUP()</code>:</p>
<ul>
<li>Data must be sorted. It will not work properly if it's not.</li>
<li>You must specify the single return column or row for the result.</li>
</ul>
<h2 id="heading-how-to-use-the-vlookup-function">How to Use the VLOOKUP Function</h2>
<p>This is a very popular function because it lets you lookup data with a little more power than the regular <code>LOOKUP</code> function.</p>
<p><strong>Here's our VLOOKUP function to return the taste: <code>=VLOOKUP(E2,All,5,FALSE)</code>.</strong></p>
<p>We're using another named range. This time, just one is needed. We have <code>All</code> which is the entire table of <code>coffee-data</code>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/range-vlookup.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Screenshot of table of data</em></p>
<p>With <code>=VLOOKUP()</code> we enter the <code>search_key</code> as before but then we give it a <code>range</code> to search. The first column in the <code>range</code> will be used to find the <code>search_key</code>. Then we give it an <code>index</code> which tells how many columns to the right we want to look for our returned value.</p>
<p>We then type in <code>FALSE</code> to indicate that our data isn't sorted. (This is actually unnecessary here since we sorted it so that the regular <code>LOOKUP</code> function would work properly).</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/image-27.png" alt="Image" width="600" height="400" loading="lazy">
<em>Screenshot of VLookup function</em></p>
<p>Shortcomings of <code>=VLOOKUP()</code>:</p>
<ul>
<li>Must lookup data from left to right.</li>
<li>Must specify a number for the index. If you add or move columns in your data, you risk breaking the formula.</li>
<li>Defaults to sorted data. In many cases, you'll need to set that argument as <code>FALSE</code> so the function will work properly.</li>
</ul>
<h2 id="heading-how-to-user-the-hlookup-function">How to User the HLOOKUP Function</h2>
<p>HLOOKUP works basically the same as VLOOKUP except that instead of searching through columns, it searches through rows.</p>
<p><strong>Here's our HLOOKUP function to return the taste: <code>=HLOOKUP(I2,hAll,5,FALSE)</code></strong></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/range-hlookup-1.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Screenshot of table of horizontal data</em></p>
<p>Check out the <code>horizontal-data</code> tab to see that I've transposed the same data set so that our <code>search_key</code> now is spread across a row instead of down a column. Then when we give an <code>index</code> value, it returns that value by counting from top to bottom:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/image-34.png" alt="Image" width="600" height="400" loading="lazy">
<em>Screenshot of HLookup function</em></p>
<p>So if we wanted the price, we'd have <code>index</code> of 2 since it's the second row down. And in our example, we return <code>taste</code> with an <code>index</code> of 5.</p>
<p>Shortcomings are the same as <code>VLOOKUP</code>.</p>
<h2 id="heading-how-to-use-the-xlookup-function">How to Use the XLOOKUP Function</h2>
<p>Enter: <code>=XLOOKUP()</code>! Microsoft released this as a successor to VLOOKUP and HLOOKUP in 2019, and Google Sheets finally added it in August of 2022. </p>
<p>What's different? </p>
<p>Well, to start with, you can use it vertically or horizontally. You don't have to specify one or the other as long as you have the proper ranges as arguments.</p>
<p>Check out both of the <code>XLOOKUP</code> blocks on the sample spreadsheet. One is using it as a vertical lookup and the second as a horizontal lookup. All that is necessary are that the ranges are correct: The <code>search_key</code> must be a single row or column, and the <code>lookup_range</code> must be of the same size depending on which is used.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/image-38.png" alt="Image" width="600" height="400" loading="lazy">
<em>Screenshot of XLookup function used vertically</em></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/image-36.png" alt="Image" width="600" height="400" loading="lazy">
<em>Screenshot of XLookup function used horizontally</em></p>
<p>Some more features/advantages:</p>
<ul>
<li><code>=XLOOKUP()</code> defaults to an exact match so you don't have to specify a <code>match_mode</code> if this is what you're after.</li>
<li>You're able to define a custom string to display as <code>missing_value</code> instead of <code>#N/A</code> in the event that nothing is returned.</li>
<li>You're able to define <code>search_mode</code> to search from the last entry to the first if you desire. In <code>VLOOKUP</code> and <code>HLOOKUP</code>, it is only possible to go first to last.</li>
<li>Instead of declaring new functions for each desired value ( <code>price</code>, <code>popularity</code>, <code>roast level</code>, and <code>taste</code> ), <code>=XLOOKUP()</code> will return each value in the given <code>lookup_range</code>. </li>
</ul>
<p>If you want don't want all the values returned, you'd need to reduce the size of the range. </p>
<p>In the spreadsheet example, I've defined my ranges <code>All</code> and <code>hAll</code> to include all the columns and rows, respectively. If I wanted to leave out taste, for instance, we'd need to leave that column/row out of the <code>lookup_range</code>.</p>
<p><code>=XLOOKUP()</code> was introduced to be the successor of <code>=VLOOKUP()</code> and <code>=HLOOKUP</code>. I think I'll be using it going forward, what about you?</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>As with most things in computer programming and spreadsheets, there are many ways to solve the same problem. </p>
<p>We've explored four ways to lookup data in a spreadsheet: <code>=LOOKUP()</code>, <code>=VLOOKUP()</code>, <code>=HLOOKUP()</code> and <code>=XLOOKUP()</code>. Each is powerful, but <code>=XLOOKUP()</code>, the newest function, is particularly useful in combining and expanding many features of its predecessors.</p>
<p>Here is a video walkthrough of everything we've discussed:</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/3TO80uky0Xg" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p>Thanks🙏for reading and watching!</p>
<p>Subscribe🔔to my YouTube channel here: <a target="_blank" href="https://www.youtube.com/@EamonnCottrell/">https://www.youtube.com/@EamonnCottrell/</a></p>
<p>And say hey👋on LinkedIn here: <a target="_blank" href="https://www.linkedin.com/in/eamonncottrell/">https://www.linkedin.com/in/eamonncottrell/</a></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Excel Tutorial – How to Clean Data with the TRIM() and CLEAN() Functions ]]>
                </title>
                <description>
                    <![CDATA[ Without clean data, your spreadsheet is knocking on death's door. In this tutorial I will show you two fast ways to clean up the data in your Excel or Google Sheets spreadsheet. When dealing with data sets, especially large ones and/or those that you... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/excel-tutorial-clean-data-with-the-trim-and-clean-functions/</link>
                <guid isPermaLink="false">66b8dde1d68a0821bf8c4748</guid>
                
                    <category>
                        <![CDATA[ data ]]>
                    </category>
                
                    <category>
                        <![CDATA[ excel ]]>
                    </category>
                
                    <category>
                        <![CDATA[ spreadsheets ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Eamonn Cottrell ]]>
                </dc:creator>
                <pubDate>Fri, 20 Jan 2023 17:42:49 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/01/clean-and-trim-fcc.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Without clean data, your spreadsheet is knocking on death's door. In this tutorial I will show you two fast ways to clean up the data in your Excel or Google Sheets spreadsheet.</p>
<p>When dealing with data sets, especially large ones and/or those that you didn't create, it is likely that you will have to clean the data in large or small ways to get it fully functional.</p>
<p>Both of the built-in functions we'll discuss – <code>=TRIM()</code> and <code>=CLEAN()</code> – are available in Microsoft Excel as well as Google Sheets. And both of them have the potential to save you a lot of head scratching. </p>
<p>Let's examine:</p>
<ol>
<li>What do we mean by clean data?</li>
<li>Why isn't it already clean?</li>
<li>How do we clean it fast and thoroughly?</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/clean-desk.gif" alt="Image" width="600" height="400" loading="lazy">
<em>a man flipping his messy desk and it becoming magically organized</em></p>
<p><em>pssst</em>: I have a video walkthrough at the bottom 👇 of the article too 😉</p>
<h2 id="heading-what-is-clean-data">What is Clean Data?</h2>
<p>In Excel and Google Sheets, the data that we work with is located in cells. In a perfect world, these cells contain properly formatted data like numbers, amounts, names, and other pieces of information.</p>
<p>However, we often encounter things in the cells which don't belong and which will prevent us from using that data in the way we need.</p>
<p>Things like non-printable characters, extra white spaces and letters in cells that should contain numbers are a few examples of unclean data which will negatively affect our work.</p>
<p>What are non-printable characters, you ask? They are the first 32 control characters in the ASCII table. </p>
<p>Check out the table below of the ASCII characters. The first 32 are non-printable control codes. These can cause issues if they somehow make it into your data set.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/char-1.png" alt="Image" width="600" height="400" loading="lazy">
<em>screenshot of ascii table in Excel</em></p>
<p>You can generate this table by using the character function for all the numbers from 0 to 255: <code>=CHAR(&lt;number&gt;)</code>.</p>
<p>The other common offenders are spaces that shouldn't be there – leading or trailing spaces in a cell. Or simply spaces in the middle that shouldn't be there.</p>
<p>Compound these finicky cells throughout a spreadsheet that contains thousands or millions of cells, and we've got quite a mess on our hands.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/a-mess.gif" alt="Image" width="600" height="400" loading="lazy">
<em>a woman waving hands and saying, "this is a mess"</em></p>
<h2 id="heading-why-isnt-the-data-clean">Why Isn't the Data Clean?</h2>
<p>Because we live in a fallen world.</p>
<p>🤣 Well, it's not that dramatic. But there can be many reasons the data isn't already clean. Many times human error is the culprit. </p>
<p>Whoever or wherever you're getting your data from simply made some mistakes with it before you got your hands on it.</p>
<p>Or maybe you messed it up when you started to manipulate the data.</p>
<p>As we'll see in the example below, the data could be perfectly fine wherever you're getting it from on the internet. But then when you import it into your spreadsheet, the conversion from HTML to Spreadsheet brings in a bunch of non-printable characters and spaces.</p>
<p>And, of course, because we're dealing with computers and people and data, we may never figure out why the data we've received isn't clean. It simply isn't. And despite our confusion, we have to clean it up to use it and extract meaning from it.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/confusion.gif" alt="Image" width="600" height="400" loading="lazy">
<em>Obi Wan visibly confused</em></p>
<h2 id="heading-how-to-clean-data-in-excel-and-google-sheets">How to Clean Data in Excel and Google Sheets</h2>
<p>Let's first get some data. In both Excel and Google Sheets, we can import data from the web. I want to bring in a table of Recipes and Ingredients from a video game website that looks like this online.</p>
<p>Here's Link...I mean, <a target="_blank" href="https://www.ign.com/wikis/the-legend-of-zelda-breath-of-the-wild/All_Recipes_and_Cookbook">here's the link</a>. ⚔️</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-153.png" alt="Image" width="600" height="400" loading="lazy">
<em>Zelda recipe table</em></p>
<p>To address the obvious question first: yes, I could just copy and paste the table. And, yes, it will in this case paste the table straight into Excel. </p>
<p>But it'll also bring in the pictures which I don't need, the links which I don't want, some formatting that I'll have to reset, and potentially some of the non-printable characters and/or spaces that we'll discuss below.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-154.png" alt="Image" width="600" height="400" loading="lazy">
<em>Table of Recipe ingredients copied straight off website</em></p>
<p>Above is what it will look like after copying and pasting. But we are interested in preserving data and cleaning it, so we'll import it another way for the sake of the rest of our discussion.</p>
<p>If you're using Excel, it has some pretty robust cleaning features out of the box. When importing data from IGN, we enter the address where it lives, and it will pull down any data that it detects as available for import.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/import.png" alt="Image" width="600" height="400" loading="lazy">
<em>screenshot of data import from web in Excel</em></p>
<p>Let's get the table of Poultry and Meat Entrée receipts from Zelda: Breath of the Wild.</p>
<p>The Navigator window shows us a handy list of data tables detected on the page as well as a preview pane on the right that can be toggled between table and website views.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/recipe-table-1.png" alt="Image" width="600" height="400" loading="lazy">
<em>Excel data import navigator window screenshot</em></p>
<h3 id="heading-excel-power-query">Excel Power Query</h3>
<p>Once we've selected our data and loaded it, we'll have imported a table into our spreadsheet just fine. Excel's Power Query features allow us to then go into this particular table and extract the values in the Ingredients column into a list of items delimited by a selector of our choice.</p>
<p>In other words, Excel is smart enough to extract the individual list items in the Ingredients column and put them in a cell one by one and separated by commas (or whatever we select to separate them).</p>
<p>The following three screenshots show this process:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/expand-values.png" alt="Image" width="600" height="400" loading="lazy">
<em>Screenshot of Excel Power Query menu</em></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/delimiter.png" alt="Image" width="600" height="400" loading="lazy">
<em>Screenshot of delimiter for expanded values</em></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/extracted.png" alt="Image" width="600" height="400" loading="lazy">
<em>Screenshot of Expanded list values in Ingredient column</em></p>
<p>The end result is a comma separated list of values that is seemingly pretty clean. We can then split it up by using the <code>=SPLIT()</code> function into separate cells if we choose, or simply use it as is.</p>
<p>This is an ideal situation. But what if we encounter those spaces and non-printable characters?</p>
<h3 id="heading-clean-and-trim-functions">Clean and Trim Functions</h3>
<p>Here's a screenshot of the same table when imported into Google Sheets with <code>=IMPORTHTML()</code>. It pulls the data correctly, but you can see the extra spaces that were also brought into the sheet.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/sheets-trim.png" alt="Image" width="600" height="400" loading="lazy">
<em>Imported data from webpage in Google Sheets</em></p>
<p>By using <code>=CLEAN()</code> on the ingredients cells, we can get rid of some non-printable carriage returns causing the line breaks.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/justclean.png" alt="Image" width="600" height="400" loading="lazy">
<em>Table after Cleaning cells</em></p>
<p>By using <code>=TRIM()</code> on the cells, we can get rid of all the leading spaces.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/justtrim.png" alt="Image" width="600" height="400" loading="lazy">
<em>Table after Trimming white spaces</em></p>
<p>And by nesting the two with <code>=CLEAN(TRIM())</code>, we can do both. The result is a list of values separated by dashes. Similarly to our resultant table in Excel where we were left with a comma-separated list, we can then go and <code>=SPLIT()</code> these values further if need be.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/both.png" alt="Image" width="600" height="400" loading="lazy">
<em>Table after cleaning and trimming at once</em></p>
<p>These functions work the same in Excel, but for illustrative purposes we used Google Sheets since it wasn't able to import the data as neatly there.</p>
<h2 id="heading-sample-spreadsheet-amp-video-walkthrough">Sample Spreadsheet &amp; Video Walkthrough</h2>
<p><a target="_blank" href="https://docs.google.com/spreadsheets/d/11j6ajxvN6dSd9U7y6LQT6IhAJvM99jRGPFcDIBtBMkM/edit?usp=sharing">Here is a link to the sample Google Sheet</a> that I made for this tutorial. </p>
<p>The first page is a table of the non-printable characters.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-155.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>And the second page is the Zelda example we talked about. Feel free to make a copy of this spreadsheet if you'd like to mess around with it further (File -&gt; Make a copy).</p>
<p>We'll be building a really cool project with some of this Zelda data soon...<a target="_blank" href="https://www.youtube.com/@eamonncottrell">follow me on YouTube</a> to keep an eye out for that.</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/mgAHQWrTcCg" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<h2 id="heading-thanks">Thanks</h2>
<p>Thanks for reading, and I hope this has been useful for you. Come say hey 👋 on <a target="_blank" href="https://www.linkedin.com/in/eamonncottrell/">LinkedIn</a> and <a target="_blank" href="https://www.youtube.com/@eamonncottrell">YouTube</a>, and I'll talk to you in the next article!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Accounting Number Format in Excel – How to Apply it to Selected Cells ]]>
                </title>
                <description>
                    <![CDATA[ In this article I will show you how to format cells in Microsoft Excel. We'll be looking particularly at the Accounting format for cells with numbers.  At the end of the article I'll give you two bonuses: a short video walkthrough of the methods we g... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/accounting-number-format-in-excel-how-to-apply-it-to-selected-cells/</link>
                <guid isPermaLink="false">66b8ddc2fedc3fd92fddb765</guid>
                
                    <category>
                        <![CDATA[ excel ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Eamonn Cottrell ]]>
                </dc:creator>
                <pubDate>Wed, 11 Jan 2023 18:11:38 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/01/currency-vs-accounting-fcc-1.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In this article I will show you how to format cells in Microsoft Excel. We'll be looking particularly at the <code>Accounting</code> format for cells with numbers. </p>
<p>At the end of the article I'll give you two bonuses: a short video walkthrough of the methods we go over, as well as a breakdown of the differences between the <code>Accounting</code> format and the <code>Currency</code> format.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/currency-vs-accounting.png" alt="Image" width="600" height="400" loading="lazy">
<em>Excel screenshot with differently formatted columns of numbers</em></p>
<p>We'll go over these three primary ways to format cells in Excel, and how to use each one to add the <code>Accounting</code> format to cells.</p>
<ol>
<li>Point and click on Home Tab in Ribbon</li>
<li>Ctrl + 1 opens format cells window</li>
<li>Keyboard Combos</li>
</ol>
<h2 id="heading-easy-mode-point-and-click">Easy Mode: Point and Click</h2>
<p>As with most things in Excel, you can indeed simply select the cell(s) you'd like to apply the <code>Accounting</code> format to and click the appropriate selection. </p>
<p>Select the Home tab from the toolbar at the top. The formatting options are found in the Number section on the Ribbon.</p>
<p>The <code>Accounting</code> format actually has its own shortcut button marked by the dollar sign.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/ribbon.png" alt="Image" width="600" height="400" loading="lazy">
<em>Excel screenshot of Ribbon</em></p>
<p>You may also select the drop-down menu to see the list of options:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-25.png" alt="Image" width="600" height="400" loading="lazy">
<em>Excel screenshot of number format options</em></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/easy.gif" alt="Image" width="600" height="400" loading="lazy">
<em>easy as that gif</em></p>
<h2 id="heading-how-to-use-the-format-cell-menu">How to Use the Format Cell Menu</h2>
<p>The selections above included the most common number formats, but you can also open the full Format Cells window by clicking the arrow in the bottom right corner of the Number section on the Ribbon.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/arrow.png" alt="Image" width="600" height="400" loading="lazy">
<em>Excel screenshot of format cell menu selection</em></p>
<p>As with all good things in computer life, there is also a shortcut to open the Format cell menu.</p>
<p>Press <code>CTRL + 1</code> to open the full menu.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-27.png" alt="Image" width="600" height="400" loading="lazy">
<em>Excel screenshot of Format Cells menu</em></p>
<p>From here you can again select the <code>Accounting</code> format and also adjust additional options like what type of money symbol and how many decimal places to use.</p>
<h2 id="heading-how-to-use-the-keyboard-combo">How to Use the Keyboard Combo</h2>
<p>Excel includes keyboard combos for every imaginable action. In many cases this can save time spent searching for and clicking the buttons on the Ribbon. </p>
<p>Keyboard combos start by pressing the <code>ALT</code> key. As soon as you press it, you'll see a ton of letters pop up on the toolbar and Ribbon.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-28.png" alt="Image" width="600" height="400" loading="lazy">
<em>Excel screenshot of ALT keyboard combo letters in Ribbon</em></p>
<p>The Keyboard Combo for <code>Accounting</code> Format is <code>ALT, H,AN</code>:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-30.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>And after you press those buttons (one after the other), you'll have selected the drop-down for <code>Accounting</code> format. The most commonly used currency symbols are displayed. <code>ENTER</code> will select the English dollar sign, or you can arrow down to another selection. </p>
<p>You can see from the screenshot above that you can also press the combo <code>ALT,H,FM</code> to open the full Format Cells window.</p>
<p>The keyboard combos offer the most nimble way to access operations and menus in Excel. Learning the ones you'll use most often can greatly improve your productivity.</p>
<p>As promised, here's an overview video walking through the topics I've discussed in this article:</p>
<h2 id="heading-video-walkthrough">Video Walkthrough</h2>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/o_cNy4JPXCA" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<h2 id="heading-accounting-vs-currency-format">Accounting vs Currency Format</h2>
<p>So, why use <code>Accounting</code> format? Isn't it just formatting the numbers with dollar signs?</p>
<p>That's a half truth. Yes, it adds a dollar sign, but so does the <code>Currency</code> format. If we open up the Format Cells window again by pressing <code>CTRL + 1</code>, we'll see that the main difference is one of alignment.</p>
<p>The <code>Currency</code> format is used for "general monetary values" and puts the dollar sign directly in front of the left-most number. The <code>Accounting</code> format, on the other hand, lines up both the dollar sign as well as the decimal in the column of numbers.</p>
<p>In terms of formatting, <code>Currency</code> will also give you options for how to display negative numbers. But in the <code>Accounting</code> format, the negative numbers will always be displayed within parenthesis. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/currency-options.png" alt="Image" width="600" height="400" loading="lazy">
<em>Format cells menu in Excel</em></p>
<h2 id="heading-thanks-for-reading">Thanks for reading!</h2>
<p>I hope this has been helpful for you. </p>
<p>Come find me on <a target="_blank" href="https://www.youtube.com/@eamonncottrell">YouTube</a> where I'm growing my coding and spreadsheet tutorial channel. And come follow and say hey over on <a target="_blank" href="https://www.linkedin.com/in/eamonncottrell/">LinkedIn</a>. 👋</p>
<p>Have a great one!</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
