fbpx
Search
Close this search box.

Making a Dynamic Dashboard in Excel [Part 3 of 4]

Share

Facebook
Twitter
LinkedIn

This is a guest post by Myles Arnott from Clarity Consultancy Services – UK.

In this post we are going to look at a simple example of the VBA behind the Dynamic Dashboard. Essentially we will learn to write macros for doing this:

Moving Charts in Dynamic Dashboard using VBA

The dynamic dashboard VBA example can be downloaded here [Mirror]

Some VBA essentials

Defining variables:
First we need to define variables “left” and “top” as integers.
Dim left As Integer
Dim top As Integer

Next we need to set a value for these variables. To do this I have created two named ranges in the Excel file called Left and Top. To make variable “left” equal to named range Left:
left = Range("Left").Value

and the equivalent for variable “top”
top = Range("Top").Value

Finally select the shape:
ActiveSheet.Shapes("Rounded Rectangle 1").Select

And define its position:
Selection.ShapeRange.top = top
Selection.ShapeRange.left = left

So the full code is:

Sub move_Image()
Dim left As Integer
Dim top As Integer

'Define the position values

left = Range("Left").Value
top = Range("Top").Value

'Select the shape and position it
ActiveSheet.Shapes("Rounded Rectangle 1").Select
Selection.ShapeRange.top = top
Selection.ShapeRange.left = left
End Sub

This code can be viewed by clicking on macros in the file.

Assign Macro to Rounded Rectangle Shape so that the Position is adjusted whenever you click on it

Once you have the code ready, you should assign it to the Rounded Rectangle 1, so that whenever you click on the rounded rectangle, the code is run.

What it does

In the downloadable file in Sheet1, enter values against the Top and Left positions in the input area (blue). Click on the shape to move it to the position you have defined.

How it works

Clicking on the shape runs macro “move_Image”.
The value for the position of the shape is linked from the named range to the variable.
The macro uses Selection.ShapeRange.top and Selection.ShapeRange.left to determine the position of the shape based on the variable value.

What Next?

We now know how to move objects using VBA. In the final part of the series learn how to pull all this together to create the dashboard.

Download the complete dashboard

Go ahead and download the dashboard excel file. The dynamic dashboard can be downloaded here [mirror, ZIP Version]

It works on Excel 2007 and above. You need to enable macros and links to make it work.

Added by PHD:

Myles has taken various important concepts like Microcharts, form controls, macros, camera snapshot, formulas etc and combined all these to create a truly outstanding dashboard. I am honored to feature his ideas and implementation here on PHD. I have learned several valuable tricks while exploring his dashboard. I am sure you would too.

If you like this tutorial please say thanks to Myles.

Related Material & Resources

This is a guest post by Myles Arnott from Clarity Consultancy Services – UK.

Facebook
Twitter
LinkedIn

Share this tip with your colleagues

Excel and Power BI tips - Chandoo.org Newsletter

Get FREE Excel + Power BI Tips

Simple, fun and useful emails, once per week.

Learn & be awesome.

Welcome to Chandoo.org

Thank you so much for visiting. My aim is to make you awesome in Excel & Power BI. I do this by sharing videos, tips, examples and downloads on this website. There are more than 1,000 pages with all things Excel, Power BI, Dashboards & VBA here. Go ahead and spend few minutes to be AWESOME.

Read my storyFREE Excel tips book

Overall I learned a lot and I thought you did a great job of explaining how to do things. This will definitely elevate my reporting in the future.
Rebekah S
Reporting Analyst
Excel formula list - 100+ examples and howto guide for you

From simple to complex, there is a formula for every occasion. Check out the list now.

Calendars, invoices, trackers and much more. All free, fun and fantastic.

Advanced Pivot Table tricks

Power Query, Data model, DAX, Filters, Slicers, Conditional formats and beautiful charts. It's all here.

Still on fence about Power BI? In this getting started guide, learn what is Power BI, how to get it and how to create your first report from scratch.

6 Responses to “Making a Dynamic Dashboard in Excel [Part 3 of 4]”

  1. Charley says:

    I got an error because "Scrolling Chart Example.xls" is not available.

  2. Charley says:

    I got an errror opening the complete dashboard file, Dynamic Dashboard Illustration V1.1.xlsm.
    It happened after enabling the macros, with the option to edit links.
    In the edit link dialog screen, there is a link mentioned "Scrolling Chart Example.xls".
    I could not find any formula that used this file in it.
    I also looked at the declared names. A lot of #REF!s in the name manager dialog screen.
    But no "Scrolling Chart Example.xls", as far as I could see.

    I sometimes get a link error in my own excelsheets and I can't find where it originates from. It looks like the source of the error is a chart, which stays linked to an external sheet. The link is not visible anywhere, so it is very difficult to find out where the link is coming from and how to correct it. The only solution I could find, was deleting the chart and making it from scratch.

  3. Jennifer says:

    I get the same error when opening the Dynamic Dashboard Illustration V1.1.xlsm file. Is the Scrolling Chart Example.xls spreadsheet available for download?

  4. Steven says:

    I was looking for the help menu as well.  Luckily I found it. Here is the link to John's page.  

    http://spreadsheetpage.com/index.php/tip/displaying_help/

  5. Joy says:

    Thanks for this four-part tutorial!

Leave a Reply