M
Mitch
The code below adds buttons to a worksheet. Data is
sorted depending on which button is selected.
This works great but it doesn't look very good for the
user because all of the columns the buttons are attached
to are different widths.
Any suggestions on how to space the buttons evenly across
the page would be appreciated. Thanks for the help....
***********************************************************
Sub Add_Buttons()
Dim btn As Button, varr, varr1
Dim i As Long
Dim cell As Range
Range("A1:A11").EntireRow.Select
Selection.Insert Shift:=xlDown
Range("A1").Select
ActiveSheet.Buttons.Delete
varr = Array("Sort1", "Sort2", "Sort3")
varr1 = Array("Customer", "Branch", "Amount")
i = 0
For Each cell In Range("A3, C3, G3")
Set btn = ActiveSheet.Buttons.Add( _
Left:=cell.Left, _
Top:=cell.Top, _
Width:=125, _
Height:=30)
btn.OnAction = varr(i)
btn.Caption = varr1(i)
btn.Name = varr1(i)
i = i + 1
Next
End Sub
sorted depending on which button is selected.
This works great but it doesn't look very good for the
user because all of the columns the buttons are attached
to are different widths.
Any suggestions on how to space the buttons evenly across
the page would be appreciated. Thanks for the help....
***********************************************************
Sub Add_Buttons()
Dim btn As Button, varr, varr1
Dim i As Long
Dim cell As Range
Range("A1:A11").EntireRow.Select
Selection.Insert Shift:=xlDown
Range("A1").Select
ActiveSheet.Buttons.Delete
varr = Array("Sort1", "Sort2", "Sort3")
varr1 = Array("Customer", "Branch", "Amount")
i = 0
For Each cell In Range("A3, C3, G3")
Set btn = ActiveSheet.Buttons.Add( _
Left:=cell.Left, _
Top:=cell.Top, _
Width:=125, _
Height:=30)
btn.OnAction = varr(i)
btn.Caption = varr1(i)
btn.Name = varr1(i)
i = i + 1
Next
End Sub