ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to code: If active cell is B1, goto H17 when enter pressed (https://www.excelbanter.com/excel-programming/401657-how-code-if-active-cell-b1-goto-h17-when-enter-pressed.html)

GregBeam

How to code: If active cell is B1, goto H17 when enter pressed
 
When the active cell is B1, I want the curser to move to cell H17 when press
enter. I need the VB code to do this (or a macro)

[email protected]

How to code: If active cell is B1, goto H17 when enter pressed
 
On Nov 26, 10:55 am, GregBeam
wrote:
When the active cell is B1, I want the curser to move to cell H17 when press
enter. I need the VB code to do this (or a macro)


Hi GregBeam,

The code below should be copied to the specific sheet to work. It
will automatically move to cell H17 if the active cell is B1. Don't
have to press Enter key.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveCell.Address = "$B$2" Then
Application.Goto Range("H17")
End If
End Sub

Regards
trevosef

Gary''s Student

How to code: If active cell is B1, goto H17 when enter pressed
 
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("B1"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
Range("H17").Select
Application.EnableEvents = True
End Sub
--
Gary''s Student - gsnu200758


"GregBeam" wrote:

When the active cell is B1, I want the curser to move to cell H17 when press
enter. I need the VB code to do this (or a macro)



All times are GMT +1. The time now is 12:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com