Friday, January 25, 2008

These Are the Good Old Days

As a sports fan, I am incredibly lucky to have moved to Boston when I did in 1996. Since I've lived here, I've been fortunate enough to see the Patriots and the Red Sox win multiple championships.

A fraternity brother of mine I hadn't heard from in a long time reminded me of this today - he remembered the time when CBS switched away from the only Pats game I was able to watch in my years at Drexel - in the first quarter - since they were getting pounded - by the Colts. I remember my friends laughing at my misery, but I proudly proclaimed that the Pats would win a SuperBowl long before the Eagles would. But who would have believed that? Things weren't looking so good back in the fall of 1992.

But things started turning around. The great Bill Parcells was hired as the head coach. The Pats drafted Drew Bledsoe. Their record went from 2-14 (1992), to 5-11 (1993), to 10-6 (1994). They actually made it to another Super Bowl in 1996, and things were looking good until Desmond Howard ran back a kickoff that broke the game open - and New England's heart. As you all know, everything changed in 2001 when Bledsoe was knocked out of a game with the Jets with a life-threatening injury, and an little-known backup named Tom Brady led our team to it's first Super Bowl. I don't know about you, but everyone watching that game with me sat in silence for a couple of minutes after Vinatieri's field goal split the uprights. We were used to disappointment, and knew that something bad was going to happen - but funny thing, it didn't. It's been one heckofa run since then.

It's interesting that when excellence becomes commonplace your perception of what is normal changes. This is especially true in the case of the Patriots. For instance, there was a point when my daughter was almost two and the Patriots hadn't lost a game in her lifetime. The day after they won the Super Bowl in 2001, I stopped at the Sports Authority on the way into work and bought two champoinship shirts, because who knew how long it was going to be until they won another one - if at all? When they did it again in 2003, I bought one shirt a couple of months later when they were on sale. I can't even find the shirt I bought in 2004. They were one catch shy of going to the SuperBowl last year, and they're going again this year!

This is how it must have been like to be a 49ers fan when Joe Montana was QB, or a Bulls fan when Michael Jordan was leading them to multiple championships. These are the times you're going to tell your grandkids about, like your grandfather might have talked about seeing Unitas or Starr play.

So if you're a younger Pats fan: watch this team, enjoy, and appreciate what you're seeing. Who knows how long it's going to be before you can experience something like this again?

Tuesday, January 22, 2008

Here's a Quick Way to Separate a File Name from a Path in Microsoft Excel

It happened again. I was presented with a text file that contained a large list of full paths and I needed to separate the file name from the path.

I can't count the number of times I have had to rewrite this Excel macro over the years; this typically happens whenever I get a new laptop and forget to back up my Excel macro modules, but this time it's because I'm at a new job and my backups are on my external hard drive at home. It's a simple problem, but anything is annoying to have to do from scratch, so I'm finally going to document it here.

Here's what I came up with. This macro assumes you have selected the first cell in your list of files, and there is a blank row immediately following the last entry in your list. It will write the path to the column immediately to the right of the current cell and the file name two columns to the right of the current cell. If you have any data in these two columns, it will be overwritten - so make sure you insert two columns to the right of your file list if you need to.

Sub SeparateFileFromPath()
 'turn off screen updating to make macro run faster
 Application.ScreenUpdating = False
 
Dim
fullpath As String
 fullpath = ActiveCell.Value
 
' do this for the whole list of files
 Do While Len(fullpath) > 0
  Dim n As Integer
  Dim m As Integer
  n = InStrRev(fullpath, "\")
  m = Len(fullpath) - n

'everything to the left of the last '\' is the path
  Dim path As String
  path = Left(fullpath, n)

' everything to the right of the last '\' is the filename
  Dim filename As String
  filename = Right(fullpath, m)

ActiveCell.Offset(0, 1).Value = path
  ActiveCell.Offset(0, 2).Value = filename

'move to the next row
  ActiveCell.Offset(1, 0).Activate
  fullpath = ActiveCell.Value
 Loop
 
' turn screen updating back on
 Application.ScreenUpdating = True
End Sub
Enjoy! If you have any improvements, let me know in the comments; I'll give you credit and make revisions.