RETURN TO 1ST CELL OF ACTIVE ROW

annadinesh

Board Regular
Joined
Mar 1, 2017
Messages
105
Dear Team

I have datas from Coloumn A to O and I want if I reach a cell on coloumn O by pressing tab or Left Key Button then the 1st cell of the active row should activate and the same should continue to every row


regards


Dinesh Saha
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Have a try with what I came up with. The macro must be pasted in the sheet's module.
VBA Code:
Option Explicit
'change the values below to define the range in which the MACRO should operate
Const FRow     As Long = 2                        'first line - equivalent to line 2
Const LRow     As Long = 1000                     'last line - equivalent to line 1000
Const FCol     As Long = 1                        'first column - equivalent to column A
Const LCol     As Long = 15                       'last column - equivalent to column O
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim myRow  As Long
    Dim myCol  As Long
    myRow = Target.Row
    myCol = Target.Column
    If myRow >= FRow And myRow <= LRow And myCol >= FCol And myCol <= LCol Then
        If myCol = LCol Then Cells(myRow + 1, FCol).Select Else Cells(myRow, myCol + 1).Select
        If myRow = LRow And myCol = LCol Then Cells(FRow, FCol).Select
    End If
End Sub
 
Last edited:
Upvote 0
Solution
Have a try with what I came up with. The macro must be pasted in the sheet's module.
VBA Code:
Option Explicit
'change the values below to define the range in which the MACRO should operate
Const FRow     As Long = 2                        'first line - equivalent to line 2
Const LRow     As Long = 1000                     'last line - equivalent to line 1000
Const FCol     As Long = 1                        'first column - equivalent to column A
Const LCol     As Long = 15                       'last column - equivalent to column O
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim myRow  As Long
    Dim myCol  As Long
    myRow = Target.Row
    myCol = Target.Column
    If myRow >= FRow And myRow <= LRow And myCol >= FCol And myCol <= LCol Then
        If myCol = LCol Then Cells(myRow + 1, FCol).Select Else Cells(myRow, myCol + 1).Select
        If myRow = LRow And myCol = LCol Then Cells(FRow, FCol).Select
    End If
End Sub
THANKS
 
Upvote 0

Forum statistics

Threads
1,214,872
Messages
6,122,026
Members
449,061
Latest member
TheRealJoaquin

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