Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default Sort buttons by caption?

Can I sort the buttons on my sheet alphabetically by caption?

--
David
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Sort buttons by caption?

Here's a simple bubblesort which will check form controls for alphabetical
and sort them vertically.
To sort them horizontally, replace .Top with .Left

Sub testit()
Dim i As Long, j As Long, lngTemp As Long

With ActiveSheet
For i = 1 To .Shapes.Count - 1
For j = 1 To .Shapes.Count - 1
If .Shapes(j).Type = msoFormControl And .Shapes(j + 1).Type
= msoFormControl Then
If .Shapes(j).TextFrame.Characters.Text < .Shapes(j +
1).TextFrame.Characters.Text And _
.Shapes(j).Top .Shapes(j + 1).Top Then
lngTemp = .Shapes(j).Top
.Shapes(j).Top = .Shapes(j + 1).Top
.Shapes(j + 1).Top = lngTemp
End If
End If
Next
Next
End With
End Sub


"David" wrote in message
...
Can I sort the buttons on my sheet alphabetically by caption?

--
David



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default Sort buttons by caption?

Rob van Gelder wrote

Here's a simple bubblesort which will check form controls for
alphabetical and sort them vertically.
To sort them horizontally, replace .Top with .Left


Hi Rob,

Thanks for the effort. Copied code into VBE, cleaned up word wrap, and ran
it, but got unexpected results, even after ungrouping and repositioning my
active buttons (3 rows of 4 buttons to 1 vertical arrangement of 12). First
run actually "hid" one button behind another :(

After compensating for that (moving hidden button), subsequent tests did
not sort buttons -- no buttons moved from current unsorted position :(

Further, since I originally positioned these buttons precisely as desired
for the user, I would like to sort them without disturbing that position as
it takes a considerable amount of time to get them back to desired position
and regroup them. In other words, if the sort routine repositions them, I
might as well just reposition them manually to alphabetical.

--
David
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Sort buttons by caption?

David,

Not sure what's going on really.
You can send me your example as an attachment. Remove the nojunkmail- from
my e-mail.


"David" wrote in message
...
Rob van Gelder wrote

Here's a simple bubblesort which will check form controls for
alphabetical and sort them vertically.
To sort them horizontally, replace .Top with .Left


Hi Rob,

Thanks for the effort. Copied code into VBE, cleaned up word wrap, and ran
it, but got unexpected results, even after ungrouping and repositioning my
active buttons (3 rows of 4 buttons to 1 vertical arrangement of 12).

First
run actually "hid" one button behind another :(

After compensating for that (moving hidden button), subsequent tests did
not sort buttons -- no buttons moved from current unsorted position :(

Further, since I originally positioned these buttons precisely as desired
for the user, I would like to sort them without disturbing that position

as
it takes a considerable amount of time to get them back to desired

position
and regroup them. In other words, if the sort routine repositions them, I
might as well just reposition them manually to alphabetical.

--
David



Reply
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
Macro to create Sort buttons Mr X Z Excel Discussion (Misc queries) 9 July 3rd 11 09:16 AM
have toggle buttons but everytime print preview buttons move TinSandhu Excel Discussion (Misc queries) 1 October 11th 06 02:57 PM
Sort without moving buttons David P. Excel Discussion (Misc queries) 1 July 3rd 05 12:36 AM
Adding buttons in a sheet to sort data Jimbob Excel Discussion (Misc queries) 1 July 1st 05 06:27 PM
label caption Rod Taylor Excel Programming 2 July 31st 03 03:25 AM


All times are GMT +1. The time now is 10:19 PM.

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

About Us

"It's about Microsoft Excel"