Is the same sheet


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'**********************************************************************************************************
' Name:                 isTheSameSheet
' Author:               mielk | 2012-03-26
'
' Comment:              Function checks if two variables of Worksheet type refer to the same
'                       Excel worksheet.
'
' Parameters:
'   aSheet, bSheet      Excel worksheets to be compared. Order doesn't matter.
'
' Returns:
'   Boolean             True - if both variables refer to the same Excel worksheet.
'                       False - if the given variables refer to other Excel worksheets.
'
'
' --- Changes log -----------------------------------------------------------------------------------------
' 2012-03-26        mielk           Function created.
'**********************************************************************************************************
Public Function isTheSameSheet(aSheet As Excel.Worksheet, bSheet As Excel.Worksheet) As Boolean
    Const METHOD_NAME As String = "isTheSameSheet"
    '------------------------------------------------------------------------------------------------------

    isTheSameSheet = (VBA.ObjPtr(aSheet) = VBA.ObjPtr(bSheet))

End Function