ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Tabbing in excel-use VBA (https://www.excelbanter.com/excel-programming/441767-tabbing-excel-use-vba.html)

Phyllis

Tabbing in excel-use VBA
 
I was wondering if you can set tabs in excel to tab to unlocked cells only.
I can't find any information about this but it seems like it should be
possible. I am not using a form, just a spreadsheet. But I have written
alot of VBA code if there is a way to do it that way. ANy ideas.

Gord Dibben

Tabbing in excel-use VBA
 
That is the default behaviour in Excel with unlocked cells in a protected
worksheet.

But only in left to right and top to bottom order.

If your order is other that that.......................

Private Sub Worksheet_Change(ByVal Target As Range)
'Anne Troy's taborder event code
Dim aTabOrd As Variant
Dim i As Long

'Set the tab order of input cells
aTabOrd = Array("A5", "B10", "C5", "A10", "B1", "C3") 'adjust to suit

'Loop through the array of cell address
For i = LBound(aTabOrd) To UBound(aTabOrd)
'If the cell that's changed is in the array
If aTabOrd(i) = Target.Address(0, 0) Then
'If the cell that's changed is the last in the array
If i = UBound(aTabOrd) Then
'Select first cell in the array
Me.Range(aTabOrd(LBound(aTabOrd))).Select
Else
'Select next cell in the array
Me.Range(aTabOrd(i + 1)).Select
End If
End If
Next i

End Sub


Gord Dibben MS Excel MVP

On Sun, 18 Apr 2010 09:45:01 -0700, Phyllis
wrote:

I was wondering if you can set tabs in excel to tab to unlocked cells only.
I can't find any information about this but it seems like it should be
possible. I am not using a form, just a spreadsheet. But I have written
alot of VBA code if there is a way to do it that way. ANy ideas.



Phyllis

Tabbing in excel-use VBA
 
Thank you. The tabbing code works great.

"Phyllis" wrote:

I was wondering if you can set tabs in excel to tab to unlocked cells only.
I can't find any information about this but it seems like it should be
possible. I am not using a form, just a spreadsheet. But I have written
alot of VBA code if there is a way to do it that way. ANy ideas.



All times are GMT +1. The time now is 04:39 AM.

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