LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Macro to create Sort buttons

Hi Jim
Thank you for replying. Apologies for not making myself clear.
The buttons are great but they are fixed in size - I was hoping to
fill the cell that the heading was in plus if that column was resized
the button too would resize. Here is my pathetic attempt...

Sub SetupOneTime()
'adds rectangle at top of each column
'code written by Dave Peterson 2005-10-22
'screwed around with by Jim Cone 2011-06-12
' so as to use buttons instead of rectangles.

Dim myRng As Range
Dim myCell As Range
Dim curWks As Worksheet
'Dim myRect As Shape
Dim btn As Button
Dim iCol As Integer
Dim iFilter As Integer
iCol = 7 'number of columns
iFilter = 14 'width of drop down arrow


Set curWks = ActiveSheet
With curWks
Set myRng = .Range("a1").Resize(1, iCol)
For Each myCell In myRng.Cells
With myCell

Set btn = .Buttons.Add(rng.Left, rng.Top, rng.Width, rng.Height)
Selection.AutoFilter
'Set myRect = .Parent.Shapes.AddFormControl(xlButtonControl, _
Top:=.Top, Height:=.Height, _
Width:=.Width - iFilter, Left:=.Left)

End With
myRect.OnAction = ThisWorkbook.Name & "!SortTable"
myRect.TextFrame.Characters.Text = myCell.Value2
Next myCell
End With
End Sub
 
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
How to create buttons? play4you New Users to Excel 2 November 22nd 06 07:36 PM
How do I create a Macro to sort data and insert blank rows & subto karinmpfa Excel Worksheet Functions 2 April 25th 06 09:57 PM
How do I create a scroll list of macro buttons? RobertM Excel Discussion (Misc queries) 1 October 31st 05 09:50 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


All times are GMT +1. The time now is 10:30 AM.

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"