Hey everyone - I'm trying to build a macro that will insert a table into a message box. Here is my specific requirement.

I have a list of players with many rows of data that show player scores for each NBA game. I'm interested in seeing the last 3 gamesthat a player has played where it shows the following fields in the table (by the way, the cells where the players reside are not contiguous...so they are not in alphabetical order):

Player Name (column A) -- Opponent (column B) -- Date played (column M) -- Total Points (column N)


I found this code which is a good first step, but it isn't really the solution. I need to add in code to find which rows the last 3 games reside in and create a union, I suppose, that will return those rows.

Here is the code:


Public Sub TEST()

Dim myData
Dim myStr As String
Dim x As Integer
Dim myRange As Range

Set myRange = Range("A19:S27")

myData = myRange.Value

For x = 1 To UBound(myData, 1)
    myStr = myStr & myData(x, 1) & vbTab & myData(x, 2) & vbTab & myData(x, 13) & vbTab & myData(x, 14) & vbCrLf
Next x

MsgBox myStr

End Sub