Sub createNamedRanges()
Dim rangeStartingRow As Integer
rangeStartingRow = 1
Dim rowCtr As Integer
rowCtr = rangeStartingRow + 1
'a boolean flag for flow control. We'll use this to make sure we don't try to add an already existing named range
Dim nameExists As Boolean
nameExists = False
'run this procedure for every row that has data in column A, and break entirely when it encounters a blank
While (Range("A" & rowCtr).Value <> "")
'compare the value in the header column of the current row the value in the first row of this block of data.
'If it isn't the same, we've reached the end of a month's data
If (Range("A" & rangeStartingRow).Value <> Range("A" & rowCtr).Value) Then
'iterate through the existing names. If we find one that matches the name we would give to the current block of data,
'turn on the "nameExists" flag
nameExists = False
For Each s In Application.Names
If (s.Name = Range("A" & rangeStartingRow).Value) Then
nameExists = True
Exit For
End If
Next s
'Create a named range for all rows in the prior block of data. Skip this creation if the named range already exists
If (Not nameExists) Then
Range("A" & rangeStartingRow & ":ZZ" & rowCtr - 1).Name = Range("A" & rangeStartingRow).Value
End If
'update the "starting point" row to our current row. We've finished processing the prior block of data
rangeStartingRow = rowCtr
End If
'increment counter...
rowCtr = rowCtr + 1
Wend
'We've ended the loop without writing the last named range (which is the very thing we were trying to accomplish)
Range("A" & rangeStartingRow & ":ZZ" & rowCtr - 1).Name = Range("A" & rangeStartingRow).Value
End Sub