Workbook & Worksheet Activation/Deactivation

Jbone697

New Member
Joined
Jun 7, 2018
Messages
15
These are the macros I have to turn off the cell direction when using the Return Key on Sheet1 only. When I open the workbook, regardless if Sheet1 is activated or not, the cell direction is turned off. If I go to sheet1 first and then go to a different sheet, this is when it is deactivated and the cell direction turns back on. If I go to a different workbook, regardless if sheet1 is activated or not, the cell direction turns back off and I have to repeat the process to get it working correctly.

I have tried changing these macros to Sub Worksheet_Activate/Deactivate, and this causes the cell direction to turn off for any other workbooks if sheet1 is activated in the background.

Im just trying to get the cell direction to turn off for sheet1 only without it affecting any other sheet on the workbook or any other workbooks. Please help.

Code:
Option Explicit

Private Sub Workbook_Activate()
With ThisWorkbook.Sheets("Sheet1")
    'Return key stays in cell for this worksheet only
     Application.EnableEvents = False
     Application.MoveAfterReturn = False
     Application.EnableEvents = True
End With
End Sub

Private Sub Workbook_Deactivate()
With ThisWorkbook.Sheets("Sheet1")
    'Return key reverts to default after selecting any other
     Application.EnableEvents = False
     Application.MoveAfterReturn = True
     Application.EnableEvents = True
End With
End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Welcome to MrExcel!

Does this help?

Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
    Const shName = "Info" ' <-- name of sheet for "No returns"
    Select Case Sh.Name
        Case shName
            Application.MoveAfterReturn = False
        Case Else
            Application.MoveAfterReturn = True
    End Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,169
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top