Personally I'd get rid of the Global variables unless you really need them (ie. can justify a reason for having them other than needing the values in more that one function), and just pass them from one function to the next when you need to.
Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim i As Long
Dim LastRow As Long
Dim Rep As String
Dim Color As Long
Dim SortByColumn As Long
Dim SortOrder As Long
Dim Filter As Long
Filter = 1
SortByColumn = 12
SortOrder = 2
call MoodysSort(Filter, SortByColumn, SortOrder)
Option Explicit
Sub MoodysSort(filter As Long, sortByCol As Long, sortOrder As Long)
Dim i As Long
Dim lngSortIndex As Long
Dim EndRow As Long
If filter = 0 Then
'do something
Else
'do something else
End
Bookmarks