Wednesday, October 02, 2013

Filtering Data in Excel

Spreadsheet software has many valuable functions, but one that I find most useful (and use most frequently) is the data filter (aka “auto filter”).  This post will be about how to use the data filter in Microsoft Excel (the function is similar in most other spreadsheet programs).  For each example, I’ll be using a sample data set of medals won by Olympic athletes available here.

First, you have to turn on the filter.  To do this, highlight the row containing column names for your data set, then select Filter from the Data tab in the ribbon:


For Excel 2003 and prior, click the Data menu, then point to Filter, and click AutoFilter.

Once you’ve done this, you’ll see a button to the right of each column heading.  Clicking this button will give you a menu of options for sorting and filtering your list based on data in that column:


As an example, we’ll look for only records of gold medals in archery, ordered by year (ascending).  First, we’ll filter on the Sport column (uncheck Select All, then check Archery to do this quickly):


Next, filter the Gold Medals column for values greater than zero (there are multiple ways to do this, but I’m demonstrating the quickest for this particular data set):


Finally, sort the Year column ascending (smallest to largest):


This gets us to our result.  To remove the filter on any column, select the menu for that column and then select Clear Filter From <Column Name>:


As you can see, this is a simple but very powerful tool.  Enjoy!

Monday, September 16, 2013

Remove All Formatting in Excel

Let’s say you have a spreadsheet that someone built for printing or looks.  It might have gridlines, background colors, special fonts, and the like:


All you want out of this is some nice rows and columns for analysis, and the formatting is not helpful for this purpose.  How do you quickly simplify this data without updating every single column or cell?  First, select the entire worksheet (or whatever area you want to update).  Under the home tab (far right side), select Clear Formats:


Once you’ve done that, your data will be ready for use:


There’s only one drawback to this approach that I’ve found so far.  If you have date fields in your data, you’ll have to re-apply the date format to the affected columns/fields.  Otherwise, the column will display the date serial number because it has no format assigned.  Other than that, this method works great for quickly removing formatting so that you can focus on the data.

Monday, July 01, 2013

Registry Hack - Add "Edit With..." Shortcut to Context Menu (Using Notepad++)

I've had to do this several times now, so it's time to write it down.  Here are the issues:

1. The existing 'Edit with Notepad++' context menu link generates an error on execution
2. Worse, it doesn't display at all through Multi-Commander

No like!

So here's how to fix it.  First, get rid of the existing context menu entry, which you'll find under HKEY_CLASSES_ROOT/*/shellex/ANotepad++64.  Now you're ready to add the new entry:

1. Go to HKEY_CLASSES_ROOT\*\shell.
2. Right-click shell and add a new key called "Edit with Notepad++" (or whatever you want to call it).
3. Now Right-click on the key you just created, and add a new key beneath it called "command".  The end result should look like this:



4. Within the command key, modify the default string to the full path of the Notepad++ executable in quotes followed by %1.  For example:



5. Go back to your original key (Edit with Notepad++ or similar) and add a new string value called "Icon".  Modify the value to the full path of the Notepad++ executable in quotes followed by ,0.  For example:



The changes will take effect immediately, and you should now have the item in your right-click context menu:





SQL Server 2012 Linked Server for MS Access

Here's the scoop: I've installed SQL Server, but I want to use Management Studio (SSMS) to query an Access Database.  I followed the directions, and also found out that the Jet OLEDB 4.0 provider is only available for 32-bit.  But now I'm getting this error:


Text:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "[server name]".
OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "[server name]" returned message "Unspecified error". (Microsoft SQL Server, Error: 7303)
There are some solutions to similar errors, but none of them are working.  What now?  Try running SSMS as an administrator.  In fact make sure it always runs with administrative rights by right-clicking the shortcut/executable, selecting properties, and checking the "Run this program as an administrator" box:


Once you do this, SSMS will have full rights to connect to your MS Access files (and any others you'd like to query).


Remove All Images From Excel Worksheet

So I have a spreadsheet I've extracted, and it has two columns of images in it (which I don't want):


Ok, so I'll just delete the columns like I would with any other data, right?


Hm.  That didn't work.  Are you really telling me that I have to select and delete these one-by-one? NO WAY!

Thankfully, there's a quick macro you can run to get rid of all images in a worksheet like this:

Dim s As Shape
For Each s In ActiveSheet.Shapes
    s.Delete
Next

Running this will remove all these pesky images in one shot.  No fuss, no muss.

Happy deleting!

Quickly Line Up Rows/Columns in Excel

Have you ever pasted a table into Excel and gotten results like this?


No like!

Wouldn't it be nice to line up and autofit all the rows and columns in one click?  Here's a quick macro that will allow you to do just that:

    Cells.Select
  Selection.ColumnWidth = 255 
  Cells.EntireRow.AutoFit 
  Selection.ColumnWidth = 9 
  Cells.EntireColumn.AutoFit 'fit the columns

Basically, it selects all the cells, makes the column extremely wide, then autofits the rows and columns.  The result is more like this:


Much better.  Enjoy!