Excel – Random IT Utensils https://blog.adamfurmanek.pl IT, operating systems, maths, and more. Sat, 02 Jan 2021 19:03:28 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.2 Heat map in Excel https://blog.adamfurmanek.pl/2018/12/01/heat-map-in-excel/ https://blog.adamfurmanek.pl/2018/12/01/heat-map-in-excel/#respond Sat, 01 Dec 2018 09:00:54 +0000 https://blog.adamfurmanek.pl/?p=2652 Continue reading Heat map in Excel]]> If you ever wondered how to create heat maps in excel, here are two simple solutions.

Data preparation

Create two columns with data, as presented below. Next, select values in column C and choose conditional formatting in Home ribbon (see screenshot). This way you can assign colors to values. You can choose More Rules… to customize the colors.

Conditional formatting

Scatter plot to heat map

First, create ordinary scatter plot using columns A and B (with values X and Y). Next, use the macro posted here by Reddit user carry_a_laser:

Sub ColorCode()
Dim i As Integer
Dim MyCount As Integer

MyCount = ActiveChart.SeriesCollection(1).Points.Count * ActiveChart.SeriesCollection.Count

For i = 1 To MyCount

ActiveChart.SeriesCollection(1).Points(i).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.RGB = Range("C" & i + 1).DisplayFormat.Interior.Color
        

    End With
    
Next

End Sub

Put this macro in your sheet, select your chart and run the macro. All the points will get colors based on conditional formatting. It is slow in Excel 2016 (for 3000 points it takes around 2 minutes), just be patient. See the result below:

Scatter plot

Pivot tables

Select your whole data (three columns). Choose Insert -> Pivot Table and hit OK. Next, drag X to rows, Y to columns, Value to Values. You should get ordinary pivot table. Now, select values inside it and apply color formatting again. See below:

Pivot table

]]>
https://blog.adamfurmanek.pl/2018/12/01/heat-map-in-excel/feed/ 0
Executing SQL query inside Excel spreadsheet https://blog.adamfurmanek.pl/2017/12/02/executing-sql-query-inside-excel-spreadsheet/ https://blog.adamfurmanek.pl/2017/12/02/executing-sql-query-inside-excel-spreadsheet/#respond Sat, 02 Dec 2017 09:00:31 +0000 https://blog.adamfurmanek.pl/?p=2259 Continue reading Executing SQL query inside Excel spreadsheet]]> Did you know that you can execute almost any SQL query directly in your Excel spreadsheet? This can be very useful for executing queries with GROUP BY and aggregates since they cannot be generated that easily. Let’s begin. I will use Excel 2013 but this method should work in other editions as well.

First, create any spreadsheet and save it somewhere. I will use the following:

Spreadsheet

Choose Data ribbon and click From Other Sources button. Choose From Microsoft Query:

Microsoft Query button

After clicking the button you will be able to choose data source. In fact, Microsoft Query is an external application (distributed with Office). Choose Excel Files:

Excel Files

Now select your file stored on the hard drive:

Choose file

Now you should be able to add tables to your workspace. Each sheet in spreadsheet represents separate table. Add table and hit Close.

Tables

Next, click SQL button placed just below the menu bar and insert any query you would like to execute:

Query

That’s all.

]]>
https://blog.adamfurmanek.pl/2017/12/02/executing-sql-query-inside-excel-spreadsheet/feed/ 0