pivottablevlookup

How to Use VLOOKUP with Pivot Tables

Do you want to be able to use a VLOOKUP with a pivot table? While there isn’t a way to natively do so, there is a way you can make it look as though your pivot table has a lookup function within there, and make it so that it expands along with your data. Suppose you have the following pivot table, which shows employee spending:

Pivot table showing spending by employee.

Let’s say we want to look up the department that the employee belongs to, based on the following lookup table:

A lookup table in Excel.

We can’t create a field that does a lookup within a pivot table, but we can make it look as if that’s what we are doing.

Copy your pivot table formatting to make it look as though you’ve added another field

I can create a field called ‘Department’ directly next to my pivot table. And what I can do to make it look as though it’s a continuation of my pivot table is to use the Format Painter so that I can copy the formatting over. To do this, simply select the formatting for the pivot table header, click Format Painter, and then click on the new field. Now it looks as though it’s the same format as your pivot table:

Pivot table with a new field added next to it.

The one drawback is that if you adjust your pivot table, you’ll need to update the formatting. You’ll also want to make sure you don’t expect your pivot table to expand — i.e. you won’t be adding any more fields to expand it horizontally. If you do so, you’ll encounter an error saying that there isn’t enough room for your pivot table. In that case, you can insert a column. But ideally, you would set this additional field once you’ve added all the fields you plan to use in your pivot table.

Using the VLOOKUP function next to your pivot table

The next step is to use the VLOOKUP function the way your normally would. With the employee name in cell A2, and my lookup table in columns F:G, I can set my formula up as follows:

=VLOOKUP(A2,F:G,2,FALSE)

But this is still not ideal as copying this formula down to far will show errors for both grand totals and blank values:

Vlookup formula added to a pivot table.

The solution here is to add an IF statement before the VLOOKUP function. In the below example, my formula is checking for both a blank value and a ‘Grand Total’ value. If either criteria is met, it returns a blank:

=IF(OR(A2="",A2="Grand Total"),"",VLOOKUP(A2,F:G,2,FALSE))

Now I can copy my formula down and the formula won’t return a value when the value in column A is blank or is a grand total:

Vlookup formula added to a pivot table which also checks for blanks and grand totals.

Now it appears as though my lookup function is dynamic and automatically adjusting based on my pivot table selections.

Adding the field to the data set is the ideal solution

Creating a field by adding a formula next to your pivot table can work if your table never expands. But if it might need to, a more versatile option is to simply add the field into your original data set and do the lookup there.

A table in Excel.

In this data set, I’m missing the department field. But if I add the VLOOKUP formula here, I can pull in the department values right in there. The formula is setup the same and by doing it this way, I can add the field directly to my data set:

Excel table after adding a field for department.

Now, when I update my pivot table I can directly add the department field right into the Rows section:

Adding fields to a pivot table.

Then, my pivot table shows the additional field, and I won’t run into any issues whether I need to add rows or columns:

A pivot table with the department field added.

In some cases, you might just want a quick way to do a lookup and not adjust the data set, in which case the first method can be preferable. But if you are able to add the field directly into your data set, that is the ideal approach.


If you like this post on How to Use VLOOKUP with Pivot Tables, please give this site a like on Facebook and also be sure to check out some of the many templates that we have available for download. You can also follow me on Twitter and YouTube. Also, please consider buying me a coffee if you find my website helpful and would like to support it.

GetRidofWarning6

How to Get Rid of the Red Warning Bar in Microsoft Excel

Have you opened a file in Excel which contains macros in it only to find that you can’t use it, because the content is blocked? If you’ve come across the following warning bar, I’m going to show you how can you remove it once and for all.

Red warning bar in Microsoft Excel.

This is different than the yellow warning bar in the past where you can just click on Enable Content and be on your way. This fix requires an extra step.

Here’s how to get rid of the red warning bar

1. Close out of the Excel file completely.

2. Right-click on the file and select properties.

3. In the file properties, check off the option to Unblock the file and then click Apply.

4. Re-open the file, where you’ll be back to seeing the more familiar, yellow warning bar where you can select to Enable Content.

Once you click on that button, your file will now be able to run macros.

How can you prevent the red warning bar from popping up in Excel?

If you’re running Windows 11 then every Excel file that you download from the internet will have the red warning bar by default. Even if you send the file to yourself and open it from Outlook, you’ll see that error come up. There is, however, a way to get around it.

Here’s what you can to avoid encountering the red warning bar on macro-enabled Excel files:

  1. In Excel, go to File -> Options
  2. Go to the Trust Center and select Trust Center Settings
  3. Navigate to Trusted Locations
  4. Click on the button to Add new location
  5. Input a location on your computer where you plan to save macro-enabled files and click OK. You can select the option to include subfolders as well.

Any file you save in one of your trusted locations won’t get the red warning bar anymore — you’ll still have the yellow warning bar, however, depending on your macro security settings. But you’ll now able to enable content without having to close and re-open the file.


If you like this post on How to Get Rid of the Red Warning Bar in Microsoft Excel, please give this site a like on Facebook and also be sure to check out some of the many templates that we have available for download. You can also follow me on Twitter and YouTube. Also, please consider buying me a coffee if you find my website helpful and would like to support it.

sddefault

Converting Time Zones in Excel and Google Sheets

If you work on large teams and/or interact with people all over the world, you know it can be challenging trying to work with time zones. While they aren’t difficult to understand, it’s easy to make a mistake when trying to arrange a meeting, as one time might seem like it works well only to discover later on that it’s during an inconvenient time for another person. Office software like Microsoft Outlook can help with this, but you can also setup a template in Excel or Google Sheets to convert time into different time zones. In this post, I’ll show you how you can setup an easy-to-use template that can calculate these differences for you.

Creating a template to convert time into other time zones

To quickly convert time from one time zone to another, the key piece of information you need is the Greenwich Mean Time (GMT) offset. Once you know this, then it’s a matter of just making of using simple arithmetic to convert from one time zone to another.

Let’s suppose your home city is London. There is no adjustment needed as its offset is 0. For New York, the adjustment is -5, and for Sydney it is +11, and Tokyo is +9. This is during non-daylight savings times. Positives can be left without an indicator but for negative adjustments, we need to put in a negative value in front to ensure the conversions are calculated correctly.

Cities broken down by GMT adjustment.

Let’s assume London is my base time, and I sent it to 12:00:00 AM. To determine the total adjustment in hours, I need to compare to the two GMT adjustments. To convert from London to Sydney is simple as I just need to add 11 hours, and in the case of Tokyo, 9 hours. New York is a bit trickier since that is behind London — hence the negative value. To make it work with the TIMEVALUE function, I need the value to be positive. Whether I deduct 5 hours or simply add 19 hours (24-5), I end up with the same time. This means, when there is a negative difference, I can just add 24 hours. That results in my GMT hours adjustment formula looking like this.

=IF(B3-$B$2<0,B3-$B$2+24,B3-$B$2)

Where B3 is my New York GMT offset and B2 is my London GMT offset.

Next, to convert the time, I’ll use the TIMEVALUE function. This can be done with taking that time zone hours adjustment from the previous step, and putting it within the TIMEVALUE function, and adding it to my base time.

=$C$2+TIMEVALUE(D3&":00")

Where D3 is the adjustment from my previous step and C2 is my base, or home time. These calculations work the same whether you’re setting this up in Excel or Google Sheets.

You can re-use this template to do different conversions based on various parts of the world. With the correct GMT adjustments for each city, the calculations can easily be updateable.

In the screenshot below, I’ve highlighted any inputs in yellow and formulas in grey to help show how a user can modify the template to do time zone conversions.

Time zone conversions in Excel with London as the base city.

I don’t have to use London as my base city and instead I can switch it around to New York. I can also change it so that my starting time is 7:00 PM New York time. The results will be the same, and it’s just the adjustment value that changes.

Time zone conversions in Excel with New York as the base city.

If you like this post on Converting Time Zones in Excel and Google Sheets, please give this site a like on Facebook and also be sure to check out some of the many templates that we have available for download. You can also follow me on Twitter and YouTube. Also, please consider buying me a coffee if you find my website helpful and would like to support it.

heat map

Create a Heat Map in Google Sheets

Heat maps are visual representations of data where individual values are represented by colors. They are particularly useful for identifying patterns, trends, and outliers in large data sets at a glance. By using a spectrum of colors, typically ranging from cool (blue) to warm (red), heat maps make it easy to see which values are higher or lower, helping users quickly understand the data’s distribution and key insights.

Why heat maps are useful

  1. Visual Clarity: Heat maps turn complex data sets into easy-to-understand visual formats.
  2. Quick Analysis: They allow for the rapid identification of trends, patterns, and outliers.
  3. Enhanced Decision Making: By highlighting critical data points, heat maps aid in making informed business decisions.
  4. Comparative Insights: They facilitate the comparison of different data points within a set.

How to create heat maps in Google Sheets

Follow these steps to create a heat map in Google Sheets:

Step 1: Prepare Your Data

Ensure your data is organized in a clear and structured manner. Each column should represent a different variable, and each row should represent a different observation or data point. You should give Google Sheets enough data so that it can determine the location for your data points. In the example below, I have U.S. states listed in column A and values in column B. Since I’ve labeled column A as ‘State’ that gives Google Sheets sufficient information to map the data points. If I had a list of countries, then I would label the header as ‘Country.’

Table of values in Google Sheets.

Step 2: Insert the chart

Select any data point on your table and on the Insert menu, select Chart. Google Sheets will create a default chart but you can change it by selecting the Chart Type and then selecting Geo Chart from the Map section.

Selecting a geo chart in Google Sheets.

Step 3: Select the correct map

When the map chart is created, it may not automatically detect the correct area. In my example, it selects the entire world.

Map chart in Google Sheets showing the entire world.

The chart looks incorrect as nothing is filled in, but this is because I’m at too high of a level to see the values. I need to adjust my chart to focus just on the United States. To fix this, edit the chart and under the Customize tab, select the Geo settings and change the region to United States.

Selecting the region settings in Google Sheets.

You can adjust the range per your individual data set. But in this example, since my data has U.S. states only, then I need to select the United States. And once I do so, now my chart is filled in:

Map chart showing values for the United States.

Step 4: Adjust the color scales

By default, the chart shows green and red colors for high and low values, respectively. I can customize this in the Geo section as well. You can modify this so that blue colors are for the low values, green for the maximum values, and yellow for the mid-range values:

Modifying the colors on the heat map in Google Sheets.

Step 5: Modify other chart settings

The last step is, as with any other chart, modifying the font, background color, border color, and any other settings for the chart. These can also be changed in the Customize section of the chart settings.

Modifying the chart settings in Google Sheets.

Once you’re done, the heat map chart is ready to go:

A heat map chart in Google Sheets.

If you like this post on How to Create a Heat Map in Google Sheets, please give this site a like on Facebook and also be sure to check out some of the many templates that we have available for download. You can also follow me on Twitter and YouTube. Also, please consider buying me a coffee if you find my website helpful and would like to support it.

value error

How to Fix #VALUE! Errors in Excel

Microsoft Excel is a powerful tool for data analysis and financial modeling, but encountering errors like #VALUE! can be a frustrating hurdle for many users. This error generally signals an issue with the way your formulas are set up or how data is entered. Understanding the root causes of the #VALUE! error and learning how to fix it can save you time and stress. This article will explore why the #VALUE! error occurs and provide practical solutions to address it.

What Causes the #VALUE! Error?

The #VALUE! error appears in Excel when a formula contains cells that have incompatible data types or when the formula is improperly structured. Here are some common scenarios:

  1. Incorrect Data Types: This is the most frequent cause. Excel expects a certain type of data to perform calculations, but if it receives something different, it will return a #VALUE! error. For example, attempting to multiply a number by a text string will cause this error.
  2. Formula Errors: Sometimes, the error occurs because the formula is not written correctly. For instance, an extra space or a missing operator can lead to #VALUE!.
  3. Cell References: If your formula references a cell that does not contain data or contains inappropriate data (like text in a sum function), Excel will not be able to execute the calculation, resulting in a #VALUE! error.
  4. Date and Time Issues: Excel handles dates and times as serial numbers. Errors can arise when you try to perform operations on what appears to be a date or time but is actually a text string.

How to Fix the #VALUE! Error

Fixing the #VALUE! error involves checking the formula and the data types involved in the computation. Here are some steps you can take:

  1. Check Data Types: Ensure that all data used in calculations are of the correct type. Convert text to numbers if necessary by using Excel functions such as VALUE() or NUMBERVALUE().
  2. Review Formulas: Look for common mistakes like misplaced brackets, incorrect operators, or syntax errors. Excel’s formula auditing tools, found under the “Formulas” tab, can help identify and correct these issues.
  3. Clear Formats: Sometimes, cell formatting can cause issues. Clear all formatting to rule out any hidden formatting errors that might be causing the #VALUE! error.
  4. Use Error Checking: Excel has built-in error checking that can diagnose and offer fixes for various errors, including #VALUE!. This can be accessed from the “Formulas” tab, under “Formula Auditing”.
  5. Simplify Formulas: If your formula is complex, break it down into smaller parts and check each segment individually. This can help isolate the part of the formula that is causing the error.

How to Find the #VALUE! Error

In some cases, it can be difficult to locate the error. In the following example, the formula is summing up column D. But even just a single #VALUE! error within that range will be sufficient to trigger an error in a formula which is just doing a single summation. That’s because you can’t sum up values if they contain the error.

An excel table which contains a #VALUE! error.

The easiest way to find an error within the range is to do the following:

  1. Highlight the range you are checking an error for.
  2. Press F5 and select Special
  3. Select Formulas and uncheck everything except for Errors
Using the go to special menu to find errors in Excel.

After clicking OK, you will be taken to the first error cell within the range:

A range in Excel which contains a #VALUE! error.

In the highlighted cells, we see that there is an apostrophe after the 4, which turns the value into a text. To correct this, all that’s necessary is to remove the apostrophe. This will fix the calculation as Excel will now recognize the cell as a number; the formula will no longer by trying to multiply a text value against a number, and thus, no error will be present.

Repeat the steps for finding errors until you get the following message:

Best Practices to Avoid Future Errors

To prevent the recurrence of the #VALUE! error, consider the following best practices:

  • Data Validation: Use Excel’s data validation tools to ensure that the correct data types are entered into cells.
  • Template Use: Develop templates with predefined formulas and formatting to minimize the risk of errors.
  • Continuous Learning: Stay updated with Excel’s functionalities and best practices. Regular practice can help you understand and avoid common pitfalls in Excel.

The #VALUE! error in Excel typically stems from data type mismatches or formula mistakes. By carefully checking your data and formulas, and using Excel’s helpful diagnostic tools, you can efficiently resolve these errors and ensure smoother, more accurate data processing in your spreadsheets.


If you like this post on How to Fix #VALUE! Errors in Excel, please give this site a like on Facebook and also be sure to check out some of the many templates that we have available for download. You can also follow me on Twitter and YouTube. Also, please consider buying me a coffee if you find my website helpful and would like to support it.

CC Balance Transfer Savings

Calculate Interest Savings on a Credit Card Balance Transfer in Excel

A balance transfer for a credit card allows people to move the outstanding balance from one or more credit cards to a new card, often with a lower interest rate. The purpose of a balance transfer is to reduce the amount of interest paid on existing debt, which can help cardholders save money. Many credit card issuers offer promotional periods with significantly reduced interest rates, sometimes as low as 0%, for a specified duration, typically ranging from six months to 18 months.

By transferring high-interest credit card balances to a card with a lower or 0% interest rate, cardholders can save a substantial amount of money on interest payments. For example, if an individual has a $5,000 balance on a card with a 20% annual percentage rate (APR), they would accrue approximately $1,000 in interest over a year. However, if they transfer that balance to a card offering a 0% APR for 12 months, they can avoid paying any interest during the promotional period, allowing them to allocate more of their payments towards the principal balance.

Additionally, a balance transfer can simplify debt management by consolidating multiple balances into one monthly payment. This can make it easier to keep track of payments and avoid missed or late payments, which can result in additional fees and negatively impact one’s credit score. However, it’s important to be aware of balance transfer fees, which typically range from 3% to 5% of the transferred amount. Even with these fees, however, the potential interest savings often outweigh the cost, making balance transfers an attractive option for those looking to manage their debt more effectively.

In the example below, I’ll show you how an Excel spreadsheet can help you estimate just how much you might save with a balance transfer.

Calculating credit card interest savings in Excel

You can estimate the interest savings from a balance transfer in Excel using the future value (FV) function. The function takes multiple arguments:

  • Interest Rate
  • Number of Periods
  • Payment Amount
  • Present Value
  • Payment Type (beginning or end of period)

Since we are looking at monthly payments, we will need to convert the interest rate to a monthly percentage. For this, take the annual credit card rate and divide it by 12. If your credit card charges a 20% interest rate annually, dividing that by 12 will give you a monthly percentage of 1.67%. In Excel, this would be input as 0.0167.

The number of periods would represent the number of months. If it’s a six-month promotional period, then six would be your input, 12 if it’s for 12 months, and so on.

As for the payment, let’s suppose that you will pay 3% of the balance. On a $1,000 credit card balance, that would translate into a monthly payment of $30.

For the present value, we’ll enter a negative value to indicate an amount owing. The input will be -$1,000.

The last argument, for the type of payment, can be left blank, assumes that a payment will be made at the end of the period. By setting it to a 1, that will assume the payment is made at the beginning. For the purposes of estimating, however, this won’t have a significant impact on the calculation.

The complete formula for the calculation based on the above assumptions for a 12-month period is as follows:

=FV(0.2/12,12,30,-1000)

This returns a value of $824.49. This is what the balance would be after 12 months of payments. Next, let’s compare this to what the balance would be if the interest rate was 0%. This what that formula would look like:

=FV(0,12,30,-1000)

This returns a value of $640, and it’s the same as if you were to deduct $360 (12 payments of 30) from the balance. Thus, the savings from the balance transfer, before accounting for fees, would be:

824.49 – 640.00 = 184.49

Furthermore, let’s assume there is a 4% balance transfer fee. On a $1,000 balance, that would be $40. The final cost savings would be as follows:

184.49 – 40.00 = 144.49

This is just one example of a savings calculation, but let’s adjust this so that it is more adaptable to other scenarios, and create a template which can be easily modified.

Creating a template to calculate savings from balance transfers

With the logic setup, to create a template is just a matter of determining the inputs to plug into the calculation. The variables which a user should be able to adjust are as follows:

  • The current interest rate
  • The promotional rate
  • The monthly payment amount
  • The credit card balance
  • The promotional period in months
  • The balance transfer fee

For this example, I’m going to use much larger amounts to help emphasize the potential savings. These are the inputs I’ve created in my sheet:

Excel sheet with inputs for credit balances and interest rates.

Now, it’s a matter of setting up the formula which links to these values. To do this, we need to combine the following calculations:

  • The FV based on the current credit card interest rate,
  • The FV based on a 0% credit card interest rate
  • Calculating the difference between the two FV calculations
  • Deducting the balance transfer fee from the above calculation

The first FV calculation is a copy of what was used before, except this time the values are not hardcoded and are instead linked back to the input cells above:

=FV(B1/12,B5,B3,-B4)

For the second FV calculation, we just need to reference the promotional rate:

=FV(B2/12,B5,B3,-B4)

Then, we deduct the difference between these calculations:

=FV(B1/12,B5,B3,-B4)-FV(B2/12,B5,B3,-B4)

The following formula also factors in the balance transfer fee:

=(FV(B1/12,B5,B3,-B4)-FV(B2/12,B5,B3,-B4))-(B6*B4)

Assuming a $20,000 credit card balance, with a monthly payment of $600, an interest rate of 20%, a 12-month promotional period at 0%, and a 4% balance transfer fee, the total cost savings would be approximately $2,889.74. The completed template is setup as follows:

Cost savings calculation in Excel showing the benefits of a credit card balance transfer.

By setting up this template in Excel, you can adjust these inputs to do your own what-if analysis. These calculations assume that your credit card balance does not change and that you are simply paying it down and not adding to it.


If you like this post on How to Calculate Interest Savings on a Credit Card Balance Transfer in Excel, please give this site a like on Facebook and also be sure to check out some of the many templates that we have available for download. You can also follow me on Twitter and YouTube. Also, please consider buying me a coffee if you find my website helpful and would like to support it.

MensOlympicFootball

Free Men’s Olympic Football Prediction Template for Paris 2024

The Paris Olympics are taking place next month, and one of the more popular tournaments is likely to be the men’s football competition, which will include 2022 World Cup finalists France and Argentina. I have created a template in Google Sheets which will help track the tournament and allow you to make predictions with others.

Tracking matches in the template

On the main page of the template, there is a tab for Actuals where you can enter the actual results as they occur. And based on those results, the tables will automatically populate, to determine which teams will play one another in the knockout stages.

Men's 2024 olympic football match schedule.

You can also highlight countries you want to track by specify the name of country under the watchlist section below. There is also a space to adjust the time based on your time zone. In the example below, the match times are adjusted based on GMT-4. I have also chosen to highlight all the matches where either France or Argentina play.

Men's 2024 olympic football match schedule adjusted to GMT-4 settings.

Making predictions in the template

In addition to tracking the matches and results, you can also make predictions with your friends. There are five predictions tabs in the file. The tabs are the same as the actual tab. The one difference is that there is column for prediction points earned. The prediction results will compare to the actuals to determine if a result was correct and if so, the number of points that someone should have earned from that prediction.

You can adjust the points someone will earn by making changes to the scoring rules tab. Here are the default rules that are in the sheet:

Scoring rules for the Men's 2024 olympic football match template.

Points can be earned for determining the correct number of goals, the right result, score, and even if the teams were correctly predicted to be in the correct elimination stage.

To track how all the players are doing, update the scoring results tab with the name of the players — this should match the individual tabs. If you rename Player1, Player2, etc, then be sure to adjust the names on the scoring results tab. If you need more players, you can copy one of the existing player tabs.

Player standings in the prediction tab.

Try the template!

This template is available for free and you can access it by clicking on this link. It will create a copy of the file which you can then use.


If you like this free template for the Men’s Olympic Football Tournament for Paris 2024, please give this site a like on Facebook and also be sure to check out some of the many templates that we have available for download. You can also follow me on Twitter and YouTube. Also, please consider buying me a coffee if you find my website helpful and would like to support it.

MapCharts2

Creating a Map Chart in Excel and Google Sheets

If you have sales data organized by country, you can create map charts in both Excel and Google sheets. These charts can make it easy to visualize sales and identify patterns and trends. Below, I will compare the different ways to create map charts in Excel and Google Sheets, and highlight any similarities and differences.

For this example, I’m going to use a data set which just includes two fields, one for the country and one for the sales data.

Sales data by country.

Creating a map chart in Excel

To create a map chart in Excel, all you need to do is click anywhere on your data set and insert a chart. Excel will likely automatically detect the data and recommend a Filled Map as an option. But if it doesn’t, you can select a Map option under the All Charts tab:

Selecting a filled map chart in Excel.

You’ll now have a chart that displays the values based on a color scale. In this example, the larger values are in a darker shade of blue whereas the smaller values are in light blue. And if there is no data, the countries are filled in grey.

A map chart in Excel.

As with other Excel charts, you can specify a different color scheme and chart layout. In the chart below, I’ve used a theme which has a black background.

A map chart in Excel with a black background.

By using the dark theme, it makes it easier to focus on areas where there is data, as those countries stand out more prominently. You can also manually adjust the color scheme for the chart by formatting the data series. To do so, right-click on the chart, select Format Data Series and under the option for Series Color, you can specify a 3-color range. And you can adjust what the minimum, midpoint, and maximum values should look like. This logic is similar to how you might set up conditional formatting rules in Excel.

Formatting a data series in a map chart in Excel.

With more colors, readers can now see more variation in visualization.

Map chart showing three different colors.

Creating a map chart in Google Sheets

To create a map chart in Google Sheets, the process is comparable to Excel’s. Simply select a cell on your data set and when you create a chart, select the option for Geo Chart under the Map section

Selecting a Geo chart in Google Sheets.

The result is similar to Excel, with the countries being shaded based on their values:

A map chart in Google Sheets.

Under the Customize section of the chart settings, you can specify what the max, min, mid values should look like. In addition, you can specify how countries without values should be displayed.

In Google Sheets, you also have a bit more flexibility in how to zoom in on data. In the region drop down, you can specify whether you want to look at the entire world, or narrow in on specific continents.

Customizing a map chart in Google Sheets.

If I select North America, then I will only get a view of that continent, even if there is data for other countries.

A map chart in Google Sheets focusing on North America.

Google Sheets also allows you to create a Geo chart with markers, which is a bit similar but the difference is the countries are not filled in. Instead, there are circles representing the values.

A geo chart in Google Sheets using markers.

With this type of chart, you can add another field to track the size of the circles. In the following data table, I also have a field for the average sale price.

Table showing sales and average sale price by country.

The average sale prices are highest in North America and smallest in Asia, and that is visually represented in the chart below. In addition to having the colors indicating the overall sales values, I can compare the average prices by looking at the size of the circles.

A geo chart in Google Sheets using markers.

Overall, creating map charts is easy whether you’re making them in Excel or Google Sheets. In Google Sheets, however, there is some added flexibility, and the ability to use markers allows you to utilize an additional field in map charts.


If you like this post on Creating Map Charts in Excel and Google Sheets, please give this site a like on Facebook and also be sure to check out some of the many templates that we have available for download. You can also follow me on Twitter and YouTube. Also, please consider buying me a coffee if you find my website helpful and would like to support it.

TrackStocksinGoogleSheets v1

How to Track Hundreds of Stocks in Google Sheets

Google Sheets makes it easy to pull in data from the internet, including stock prices. An advantage it has over Excel’s StockHistory function is that it can pull prices even before the trading day has finished. This gives users access to more up-to-date information. Plus, it’s easy to track not just one or two stock prices in Google Sheets but even hundreds.

How to pull in a stock price for a ticker symbol in Google Sheets

Using the GOOGLEFINANCE function, you can quickly pull in a stock price easily. Here are the main components of the function:

  • Ticker
  • Attribute. Below are the attributes you can use for stocks:
    • “price”: current price, up to 20 minutes delayed.
    • “priceopen”: the opening price.
    • “high”: the current day high.
    • “low”: the current day low.
    • “volume”: the current day’s volume.
    • “marketcap”: the stock’s current market cap.
    • “tradetime”: the time the last trade was made.
    • “datadelay”: how delayed the real-time data is.
    • “volumeavg”: the stock’s average trading volume.
    • “pe”: the price-to-earnings ratio.
    • “eps”: the most recent earnings per share.
    • “high52”: the stock’s 52-week high.
    • “low52′: the stock’s 52-week low.
    • “change”: the change in stock price from the previous day’s close.
    • “changepct”: the percentage change in price from the previous day’s close.
    • “beta”: the stock’s beta value.
    • “closeyest”: the previous day’s closing price.
    • “shares”: the number of shares outstanding.
    • “currency”: the stock’s currency
  • Start Date
  • End Date
  • Interval

You don’t, however, need to fill in all of the arguments. For example, the following formula only uses the ticker and the attribute field and it will pull in Amazon’s current stock price:

=GOOGLEFINANCE(“AMZN”,”price”)

If you want to pull in Amazon’s stock price for the first trading day of the year, you could use the following formula:

=GOOGLEFINANCE(“AMZN”,”price”,”1/1/2024″)

This will return the following table:

Amazon's stock price for Jan. 2, 2024.

Although January 1 was not a trading day, the formula automatically gets the data for the next trading day. If you just want to get the closing price and don’t want the rest of the table, you can nest this formula within the INDEX function as follows:

=INDEX(GOOGLEFINANCE(“AMZN”,”price”,”1/1/2024″),2,2)

Since we are getting the second column and the second row, it will only retrieve the closing price for that day. This method works when you are just pulling in the stock price for a single date.

Adding a prefix for exchanges

If you want to track a lot of stocks, the one thing you may inevitably run into is a situation where Google Sheets doesn’t correctly identify your stock ticker. If, for example, you want to pull in a stock from a different exchange, entering just the ticker symbol alone won’t be enough. If I wanted to pull in the price for Air Canada stock, which has a ticker symbol AC on the Toronto Stock Exchange (TSX), this formula won’t work:

=GOOGLEFINANCE(“AC”,”price”)

Instead, that formula will return the value for Associated Capital Group, which trades on the NYSE. Google Sheets effectively takes its best guess as to which ticker you want to pull in. But as you can imagine, it may get it wrong if you have a symbol which is active on multiple exchanges.

To get around this, you can incorporate an indicator for the exchange. For the TSX, it’s TSE. If you’re not sure which one to use, go to the Google Finance website and look for the stock you want, and take note of the code for the exchange:

Google Finance quote showing the stock ticker and the exchange code.

To ensure the GOOGLEFINANCE function is retrieving the correct stock, I can adjust my formula as follows:

=GOOGLEFINANCE(“TSE:AC”,”price”)

You can follow the same methodology for other stocks and exchanges.

Creating a template to track hundreds of stocks

To create a template to help you track stocks in Google Sheets, all you really need are a few fields. One for the ticker, one for the exchange, plus one for the stock price. I’ll also add one for the % change. This can help you build out a dashboard.

If I have my tickers in column A and the exchange code in column B, I can combine the values to create a dynamic formula which will update based on those combinations. This way, I can avoid having to hardcode the individual stock tickers. Here’s how that formula would look:

=GOOGLEFINANCE(B2&”:”&A2,”price”)

The key is to combine those values and separate them with a colon in-between, so that the format is exchange:ticker. Now, when I create my template, I can copy that formula down and it will pull in stock prices which aren’t based solely on just the stock ticker:

Stock prices in Google Sheets based on multiple tickers.

Let’s extend this a bit further and now also include the percent change from the previous day. If I want to format it as a percentage, I need to make sure I divide the value by 100:

=GOOGLEFINANCE(B2&”:”&A2,”changepct”)/100

And now I can display both the stock price and the percent change from the previous day:

Stock prices in Google Sheets based on multiple tickers showing the price and the percent change.

You can copy these formulas down hundreds of rows, making it possible to track as many stocks as you need in Google Sheets.


If you like this post on How to Track Hundreds of Stocks in Google Sheets, please give this site a like on Facebook and also be sure to check out some of the many templates that we have available for download. You can also follow me on Twitter and YouTube. Also, please consider buying me a coffee if you find my website helpful and would like to support it.

DatabasesinExcel

Create a Database Entry Form in Excel to Populate a Sheet Using VBA Macros

Excel isn’t a database software but as long as you don’t need to manage millions of data points or have complex, interlocking systems, it can potentially do the job for you — and save you plenty of money. You can create forms, that with the use of visual basic, can populate a database which you can track within Excel and then create reports on later.

Designing a user form and database sheet

Let’s suppose we want to track sales and commission data. A form that someone may fill out could include the following fields:

  • Sales Rep
  • Store
  • Date
  • Product
  • Sale Amount

Upon entering this data, a user could click on a button to post the data to another sheet within the workbook, thereby adding it to a database. And with more entries, the data can grow over size. We could then use the data to run reports on and to track store sales, calculate commission, and other metrics.

Here’s how I’ve designed this form in Excel:

A sales entry form in Excel.

The ‘Post Data’ button was created using a shape. And it will be attached to a macro, which will then post to the database worksheet.

Next, I’ll create the corresponding fields where these values will post to on a separate sheet, which I’ll call the database sheet. The layout is a simple one which just involves the same headers from the sales entry form.

A database sheet contain the fields from the data entry form.

Populating the database sheet using a macro

Next, I’ll create a macro to copy the data from the sales entry form to the next row in the database sheet.

The following macro will find the next row in the database sheet, and then copy the values from the sales entry form into the corresponding field. I’ve also added a message box at the end to let the user know that the data was posted successfully to the database sheet. My inputs in cells C4:C8.

Sub copyinputs()

Dim cl As Range
Dim nextrow As Double
Dim wsinput As Worksheet
Dim wsdatabase As Worksheet

'set the worksheet variables
Set wsinput = Worksheets("Input")
Set wsdatabase = Worksheets("Database")

'detect the next available row based on values in column A
nextrow = WorksheetFunction.CountA(wsdatabase.Range("A:A")) + 1

'copy values over
wsinput.Range("C4").Copy wsdatabase.Range("A" & nextrow) ' copy the sales rep
wsinput.Range("C5").Copy wsdatabase.Range("B" & nextrow) ' copy the store
wsinput.Range("C6").Copy wsdatabase.Range("C" & nextrow) ' copy the date value
wsinput.Range("C7").Copy wsdatabase.Range("D" & nextrow) ' copy the product
wsinput.Range("C8").Copy wsdatabase.Range("E" & nextrow) ' copy the sale amount

MsgBox "Posted!"

End Sub

This macro, called copyinputs still needs to be assigned to the button. To do this, I need to right-click on the button on the sales entry form and select Assign Macro and then select this macro. After doing this, I can start entering data and populating my database. When I finish filling in my data and I click on the Post Data button, I get a message saying it has been posted.

Entering data on the sales entry form in Excel.

And in my database sheet, it has begun populating the data:

Database sheet in Excel containing data from the input page.

As I enter data and click on the Post Data button, it continues adding to my database:

The database sheet growing in size.

Since it is always calculating the next row, it isn’t overwriting the existing information.

Additional macros to setup

This current macro is a simple one which just posts the data. It doesn’t do anything besides that. It doesn’t check for if the fields are entered nor does it clear them after they’ve been entered. You can adjust this, however, to make the macro and form more robust.

Here’s a macro which includes the existing code plus code to clear the values after they’ve been entered, assuming the values are in the range C4:C8.

Sub copyinputs()

Dim cl As Range
Dim nextrow As Double
Dim wsinput As Worksheet
Dim wsdatabase As Worksheet

'set the worksheet variables
Set wsinput = Worksheets("Input")
Set wsdatabase = Worksheets("Database")

'detect the next available row based on values in column A
nextrow = WorksheetFunction.CountA(wsdatabase.Range("A:A")) + 1

'copy values over
wsinput.Range("C4").Copy wsdatabase.Range("A" & nextrow) ' copy the sales rep
wsinput.Range("C5").Copy wsdatabase.Range("B" & nextrow) ' copy the store
wsinput.Range("C6").Copy wsdatabase.Range("C" & nextrow) ' copy the date value
wsinput.Range("C7").Copy wsdatabase.Range("D" & nextrow) ' copy the product
wsinput.Range("C8").Copy wsdatabase.Range("E" & nextrow) ' copy the sale amount

'clear the data
wsinput.Range("C4:C8").ClearContents

MsgBox "Posted!"


End Sub

Additionally, we can setup rules to make sure that the fields have to be entered fully before clicking on the Post Data button. This can prevent incomplete entries from being posted to the database sheet. Here’s how we can add a code to check if the sales rep field contains a value. This can be repeated for all other required fields:

Sub copyinputs()

Dim cl As Range
Dim nextrow As Double
Dim wsinput As Worksheet
Dim wsdatabase As Worksheet

'set the worksheet variables
Set wsinput = Worksheets("Input")
Set wsdatabase = Worksheets("Database")

'detect the next available row based on values in column A
nextrow = WorksheetFunction.CountA(wsdatabase.Range("A:A")) + 1

'check if the sales rep field contains a value
If wsinput.Range("C4") = "" Then
    MsgBox "Please enter a sales rep"
    Exit Sub
End If


'copy values over
wsinput.Range("C4").Copy wsdatabase.Range("A" & nextrow) ' copy the sales rep
wsinput.Range("C5").Copy wsdatabase.Range("B" & nextrow) ' copy the store
wsinput.Range("C6").Copy wsdatabase.Range("C" & nextrow) ' copy the date value
wsinput.Range("C7").Copy wsdatabase.Range("D" & nextrow) ' copy the product
wsinput.Range("C8").Copy wsdatabase.Range("E" & nextrow) ' copy the sale amount

'clear the data
wsinput.Range("C4:C8").ClearContents

MsgBox "Posted!"


End Sub


If you like this post on Create a Database Entry Form in Excel to Populate a Sheet Using VBA Macros please give this site a like on Facebook and also be sure to check out some of the many templates that we have available for download. You can also follow me on Twitter and YouTube. Also, please consider buying me a coffee if you find my website helpful and would like to support it.