Home |
Search |
Today's Posts |
#8
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to create buttons? | New Users to Excel | |||
How do I create a Macro to sort data and insert blank rows & subto | Excel Worksheet Functions | |||
How do I create a scroll list of macro buttons? | Excel Discussion (Misc queries) | |||
Sort without moving buttons | Excel Discussion (Misc queries) | |||
Adding buttons in a sheet to sort data | Excel Discussion (Misc queries) |