LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Set tabindex automatically

When something doesn't work it's helpful for others to have an idea of what
doesn't work. Eg, I'm quite sure the example posted by John will work,
though potentially it might end up with incorrect tab indexes (change one
can change none, some or all others).

The error with mine, on which line and what's the message. Even though the
code is fine the error could be due to loads of things.

Insert the following as the first lines of code

On Error Resume Next
If ThisWorkbook.VBProject.Name = "dummy" Then:
If Err.Number Then
MsgBox "Ensure ''Trust access to Visual Basic Project''" & vbCr _
& "in Macro Security is allowed"
Exit Sub
End If
On Error GoTo 0

Carefully follow the notes

500 controls ?

Regards,
Peter T





"Paul" wrote in message
...
Peter,

Thanks for your reply,

I'm getting a 1004 error when running your code, any suggestions?

Cheers,

Paul.

"Peter T" wrote:

Try this -

Sub myTabOrder()
' dump control names to cells
' select re-sorted controls in tab index order high first
' change bDump True/false and form name to suit
Dim bDup As Boolean
Dim i As Long
Dim cel As Range
Dim ctr As Object

bDump = True ' read

With ThisWorkbook.VBProject.VBComponents("UserForm1").D esigner

If bDump Then ' read

For Each ctr In .Controls
' this order will always be the order
' controls were added to the form
i = i + 1
Cells(i, 1) = ctr.Name
Cells(i, 2) = ctr.TabIndex

Next
''''''''''''''''''''''
'' discard any controls whose container is not the form
'' eg in frames or page controls
'' Sort controls in order highest tabindex to lowest
'' note first tabindex is 0,
'' eg if nine controls in order is 8-0
'' Select cells with the control names
'''''''''''''''''''''''''''

Else
For Each cel In Selection
.Controls(cel.Value).TabIndex = 0
Next
End If
End With

End Sub


Regards,
Peter T
"Paul" wrote in message
...
Hi,

I've got a userform with a lot of textboxes, comboboxes etc. During
development there was a lot dragging those boxes all over the form, and
offcourse the tabindexes are now totally off!

Is there a way to, via a macro or something, to automatically set the
tabindexes the way I would like them?

Cheers,

Paul






 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Textbox inserted on an Excel sheet does not allow TABINDEX or SetF Raky Excel Programming 1 July 2nd 08 10:20 AM
Order the TabIndex clara Excel Programming 1 April 30th 07 07:56 PM
multipage tabindex JT Excel Programming 5 October 26th 05 01:07 PM
Problem with Tabindex Toppers Excel Worksheet Functions 0 February 5th 05 08:27 AM
TabIndex property Brett[_5_] Excel Programming 1 August 11th 04 04:06 PM


All times are GMT +1. The time now is 03:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"