how can I make tabs work only in the colums being used?

L

lecielbleu

Tabs move from colum to colum to the right. But, it keeps going to right
colums.
How can I make the tabs move right only until the last colum that I am
using, then move to the next row?

Thanks for your answer in advance.
 
G

Gord Dibben

Start in A1

Tab to B1,C1,D1,E1,F1 entering data as you go.

When you leave F1 hit the ENTER ley to return to column A and one cell
down........A2

You will always go back to the column you started from.

i.e. start in C1.........go back to C2

OR unlock columns A:F and protect the sheet.

Tab key will go across to F then back to A one row down.

I prefer the first method because protecting a sheet can cause other problems.


Gord Dibben MS Excel MVP
 
K

Ken Johnson

If it really really really has to be the Tab key then select those
columns or use a Worksheet_SelectionChange event procedure such as...

Option Explicit
Public rngPreviousCell As Range
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim lLastColumn As Long
lLastColumn = Cells(1, Range("1:1").Columns.Count).End(xlToLeft).Column
On Error Resume Next
If rngPreviousCell.Column < lLastColumn + 1 Then
On Error GoTo 0
If ActiveCell.Column = lLastColumn + 1 Then
Application.EnableEvents = False
ActiveCell.Offset(1, -lLastColumn).Select
End If
Application.EnableEvents = True
End If
Set rngPreviousCell = ActiveCell
End Sub

which keeps the Tabbed-to-cell within the columns from column A up to
the last used column. To get out of that range you will have to select
a cell in the column after the next available column, since the code
relies on the selection of a cell in the next available column to take
the selection to the next row down.

Ken Johnson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top