All articles in 'VBA Macros' Category
Few days ago, I saw a beautiful homemade science experiment on Sand Pendulums on Bruce Yeany‘s YouTube channel. Go ahead and check it out. It is a cool project to do with your kids.
I will try this experiment with kids during school term holidays around Easter. But first, I wanted to try the simulation in Excel.
Simulating sand pendulum pattern in Excel
Take a look at the final simulation above. This is what we will create in Excel.Continue »
As part of a my ongoing consulting gig, I often run painfully long queries on SQL Server to fetch data. This data obviously ends up in Excel for further analysis. Now, some of these queries return NULL values in several columns (did I tell you that the queries have a gazillion left joins on them, oh yeah, they do). Although technically NULL is nothing, when you import this data to Excel, we get the text value NULL in the cells. And I don’t need these NULL values messing up all the calculations and pivots.
Of course, we can go ahead and use the isnull() SQL function to deal with them at the query level. But since the queries have 100s of columns and used by various teams for different purposes, changing them causes a lot of pain. So I did what any sensible Excel user would do. Just kill those NULLs mercilessly once they are in Excel.Continue »
I started a new consulting gig with NZ Ministry of Business (aside: when I told my daughter about this, she widened her eyes and said ministry of MAGIC!!! ). On my first day, while having lunch in breakout area, I chatted with the gentleman sitting opposite me. We got talking about this and that and eventually the topic turned to What I do at MB. So I told him that I am helping the HR with some data analysis and reporting using Excel & SQL Server. He asks me, “So you must be familiar with Excel object model”. I said, “oh, why yes”. He then asks me, “I have this problem that is bothering me for years. You see, I get a lot of data. And I use Find (Ctrl+F) to find all the cells that contain certain code. But the results are all over the place. I want to know how to extract all the finds to a target worksheet – value & address format.”
I explained him how to do this while chewing mouthfuls of rice & veggies.
But once I am home, I thought, “hey, maybe there are others out in the world who want to do this”.
So here we go.Continue »
It is election time in USA, and that means there is a whole lot of drama, discussions and of course data analysis. There are tons of cool visualizations published on all the data. Previously, we talked about “How Trump happened” chart.
Today let’s take a look at the beautiful decision tree chart by NY Times explaining what would happen if each of the 10 swing states vote for Democrats or Republicans. Go ahead and look at that chart. And when you are done playing with it, come back.
My first thought after looking at the chart is: Wow, that is cool. I wonder how we can recreate that experience in Excel?
But as you can guess, making a dynamic tree visualization in Excel is pretty hard. You can create a bubble chart mixed with XY chart to show all the nodes of the decision tree, but as this tree has 2^10 nodes at the bottom level (and 2^11-1 total nodes) our chart would look very clumsy and busy.
So, instead of replicating NY Times chart, why not make our own version that explains the data? You can reuse this idea when visualizing outcomes of several what-if scenarios.Continue »
Anyone who has made a pivot table and their grandma knows that formatting them is a pain. Let’s recap the steps to apply one of the most common formats – currency format.
- Right click on any value field
- Go to Value field settings
- Click on “Number Format” button
- Choose Currency format
- Close the boxes, one after another
Unless you get paid per click, you wont be happy with all those clicks.
Wouldn’t it be cool to just click once and apply most common format to your pivot fields?
Of course you can. Just add oneClickCurrency macro to your personal macros workbook. And then add this to your Home ribbon as a custom button and you have a one click format option for any pivot.Continue »
My twins (Nishanth & Nakshtra) are now almost 7. They are super keen to learn how computers work. So the other day, I showed them Code.org where there are several coding exercises disguised as games. They loved those games … err coding exercises. So that got me thinking… why not make a game in Excel that teaches kids simple programming concepts.
So I built a Snowman & Hot Chocolate Maze game. In this post, let’s understand how to build such a game using Excel VBA.Continue »
Recently I saw an interesting Earth Venus cosmic dance video on Facebook. See the original video below or here.
Although this is not entirely accurate from physics & astronomy perspectives, the dance is a stunning example of patterns that are generated by simple things.
I wanted to recreate this cosmic dance in Excel. How else am I to get my spreadsheet fix on a Saturday?
Here is a quick demo of the final outcome. Read on to learn more about the Earth Venus cosmic dance.Continue »
As announced earlier, here is the first one of our Master Classes. In this one, you will learn how to create advanced interactive charts in Excel by blending pivot tables, slicers, timelines, VBA, conditional formatting and charts. The final outcome is BEAUTIFUL!!! Monthly Master Class – Episode 1 – Trailer Check out a quick trailer of the […]Continue »
During last week, an alert reader of our blog, Jørgen emailed me a link to “How Trump happened“. It is an interactive visualization by Wall Street Journal. Jørgen asked me if we could replicate the visualization in Excel. My response: “Making a new chart in Excel? Hell yeah!”
Read on for awesome visualizations and full explanation.Continue »
Here is an interesting problem to keep you busy.
Transpose the address data in column A into the format indicated in C:G using either VBA, formulas or Power Query. Once done, post your answers in comments section.Continue »
Hello all, prepare to be amazed! Here are 43 creative, fun & informative ways to visualize KPI data.
About a month ago, I asked you to visualize KPI data. We received 65 entries for this contest. After carefully reviewing the entries, our panel of judges have discarded 22 of them due to poor charting choices, errors or just plain data dumps. We are left with 43 amazing entries, each creatively analyzed the data and presented results in a powerful way.
How to read this post?
This is a fairly large post. If you are reading this in email or news-reader, it may not look properly. Click here to read it on chandoo.org.
- Each entry is shown in a box with the contestant’s name on top. Entries are shown in alphabetical order of contestant’s name.
- You can see a snapshot of the entry and more thumbnails below.
- The thumb-nails are click-able, so that you can enlarge and see the details.
- You can download the contest entry workbook, see & play with the files.
- You can read my comments at the bottom.
- At the bottom of this post, you can find a list of key charting & dashboard design techniques. Go thru them to learn how to create similar reports at work.
Thank you very much for all the participants in this contest. I have thoroughly enjoyed exploring your work & learned a lot from them. I am sure you had fun creating these too.
So go ahead and enjoy the entries.Continue »
In the 48th session of Chandoo.org podcast, let’s make some animated charts!!!
What is in this session?
In this podcast,
- Why animate your charts?
- Non-VBA methods to animate charts
- Excel 2013’s built-in animation effects
- Iterative formula approach
- VBA based animation
- Cartoon film analogy
- Understanding the VBA part
- Example animated chart – Sales of a new product
- Resources and downloads for you
Today is Diwali, the festival of lights. I wish you and your family a happy, bright and prosperous festive time. May your house shower with lots of light, laughter and love.
Diwali is one of my favorite festivals. It is a time when all family members get together, eat delicious food, laugh to hearts content and light up diyas (small oil lamps) to celebrate the victory of good over evil. This year, my kids (who are 6 yrs btw) are very excited about the festival. They are looking forward to lighting up diyas and crackers (fire works).
To celebrate the holiday, I made something for you.
An animated flower pot firework in Excel.Continue »
Last night I asked members of our Chandoo.org facebook page to share an Excel problem you are struggling with. Francis asked,
How to save a file as .txt in vba without quotes? When I save as .txt, the file has got quotes inside of it. I used the code Print, but it didnt work because the file loses its delimitation.
Does anyone know how to solve this?
Let’s understand how to save a range as text and overcome the double quote problem.Continue »
Here is a familiar scenario: You are building a dashboard. Naturally, it has a few worksheets – data, assumptions, calculations and output. As you make changes to input data, you constantly switch to calculations (or output) page to check if the numbers are calculating as desired. This back and forth is slows you down.
Use Watch Window to reduce development time.Continue »