How to check if particular sheet is an active sheet or not?
I want particular functionality to be used for worksheet having name Data.
I can check if Data sheet exists or not using following code
Dim ws As Worksheet
Set ws = Wb.Sheets("Data")
If ws Is Nothing Then
Else
But how to check if Data sheet is an active sheet or not ?
is there any thing like
If ws Is Activesheet Then
UPDATE:
I have added following code in the one of the Class module of addin.
What i am trying to do is to manage other excel sheets from this addin. I want to call procedure paste_cells if the the active sheet is having name “Data”.
Public WithEvents App As Application
Private Sub App_WorkbookActivate(ByVal Wb As Workbook)
MsgBox "Activate"
Dim ws As Worksheet
Set ws = Wb.Sheets("Data")
If ws Is ActiveSheet Then ' if active sheet is having name Data
App.OnKey "^v", Procedure:="Paste_cell" 'paste cell is procedure i want to add when active sheet is Data
Else
App.OnKey "^v"
End If
End Sub
you should
For an addin you would normally use ActiveWorkbook,ie